Forum Discussion

BerntOve's avatar
BerntOve
Ideator I
3 years ago

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:

 

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.

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:cdb7d76d-02e5-42c4-96a0-74ad83b5e671:type=javascript&text=var%20taskItem%20%3D%20aras.newIOMItem%28%27Task%27%2C%20%27edit%27%29%3B%0D%0Avar%20tgvContext%20%3D%20inArgs.contextParams.tgvContext%3B%0D%0Avar%20tgvGrid%20%3D%20tgvContext.grid%3B%0D%0Avar%20tgvGridData%20%3D%20tgvContext.getGridData%28%29%0D%0A%0D%0Avar%20dataObject%20%3D%20tgvGridData.focus%5B0%5D.row.cells%5B0%5D.data%3B%0D%0Aaras.AlertError%28%22Result%3A%20%22%20%2B%20dataObject%29%3B]

as shown from the output i get "INVALID_ID_VALUE"

Hope somebody can assist here.

5 Replies

  • I've seen children as young as 8 years old playing the game referred to as monkey mart. You can tell a lot about people through their voices. Because they don't actually play the game in a competitive manner and they occasionally simply do whatever they want in it, they can be quite unpleasant. They also tend to make a lot of noise. Uninterrupted yelling and talking both. Yes.

  • 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

    • BerntOve's avatar
      BerntOve
      Ideator I

      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

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        I right now noticed that my code never would have worked in your scenario. Why should you parse something that is already invalid? You just get an even more invalid result...

        Happy to hear that you solved it!