Getting Item id from custom context method on Tree Grid View

Hi,

I have two new ItemTypes that i use to add project activities and tasks to the Part ItemType like this:

 Part, Project Activity, and Tasks Relationships

I have created a new query definition and tree grid view to display the structure on a new tab on the Part:

I have also created a custom context menu item with corresponsing method that is intended to set the Done property on the selected task.

The issue i am struggeling with is that i cant get the Item id of the selected row.

var taskItem = aras.newIOMItem('Task', 'edit');
var tgvContext = inArgs.contextParams.tgvContext;
var tgvGrid = tgvContext.grid;
var tgvGridData = tgvContext.getGridData()

var dataObject = tgvGridData.focus[0].row.cells[0].data;
aras.AlertError("Result: " + dataObject);

as shown from the output i get "INVALID_ID_VALUE"

Hope somebody can assist here.

Parents
  • Hi!

    You need some additional code to get the id. Something like this:

    const dataObjectAsString = gridData.focus[0].row.cells[0].data;
    const dataObject = JSON.parse(dataObjectAsString);

    const itemId = dataObject.id;

    Angela

  • Hi Angelalp,

    Thanks for the feedback. It still showed the same invalid id with the added parse code.

    But, i found the root issue and it was related to the configuration of the Tree Grid View. The "Data Template" on the mapped element was incorrect. When i updated it to "{"id": "{Task.id}", "type": "Task"}" on the Task name property everything worked as intended.

    Bernt Ove

Reply
  • Hi Angelalp,

    Thanks for the feedback. It still showed the same invalid id with the added parse code.

    But, i found the root issue and it was related to the configuration of the Tree Grid View. The "Data Template" on the mapped element was incorrect. When i updated it to "{"id": "{Task.id}", "type": "Task"}" on the Task name property everything worked as intended.

    Bernt Ove

Children