How to edit individual relationship properties from a Form?

Hi community,

has anyone of you experience with editing multiple relationship properties directly from a Form?

I have an ItemType with a couple of sub relationships, something like this:

-- MyTopItemType
-----Null-Relationship 1
-------Null-Relationship 2
---------Null-Relationship 3

I don´t want the users to have to click through all the relationship levels, so I want to provide an alternative rendering of ALL levels inside a Form. I want to completely hide the relationships later.

Display all the data at once is not a problem. We can use fetch/getRelationships to get the individual levels when user open the Form and then display the data. I right now use a simply table rendering that groups the different levels.

Some of the cells in the table are (custom) dropdowns where use can select values that shall later be stored in the corresponding relationship.

I am right now struggle to find the best way to update the relationships without using too much individual queries.

One working solution was to fire an edit query each time user change a cell value. But this one will fire a lot of events.
I think a better way would be just edit the existing context item and then store the updated values in the database once the users clicks "Save".

Editing the context item / document.thisItem some kind of works, but the values will not be stored reliable. I tried this one:

// Get the relationshps from level 1
var NullRel1Items = document.thisItem.fetchRelationships("MyTopItemType").getRelationships("NullRel1Item");

// Edit one single relatiionship from level 1
NullRel1Items.getItemByIndex(0).setProperty("mycustomproperty","newvalue");
NullRel1Items.node.setAttribute("action", "update");

This variant works from a button event. It will not live-update the relationships, but store the new value when users click save. But I have to fetch the main item including all relationships every time again and again. I weren´t able to reuse the current context item. So this variant hadn´t worked when fired from multiple cells. 

Does anyone know a working variant to edit relationships? I know that Aras does similar editing inside Innovator. But have haven´t find a easy to reuse sample yet. So any hints would be welcomed!

Thanks!

Angela

Parents
  • I made some progress by using this variant:

        aras.setItemProperty(myDocRelations.node,"mycustomprop","mynewvalue"); 

    This will update the relationship property. But I cannot close the main item anymore after edit. The tab pane will crash and I will get the following error message in the browser debugger:

    'factory.js: 74 Uncaught (in promise) CUIError: The command for the command alias 'UnclaimItem' failed. '

    A somehow working variant is the following were I immediately save the changed relationship:

       aras.setItemProperty(myDocRelations.node,"mycustomprop","mynewvalue"); 
       aras.saveItemEx(relshipNode,false);

    But I want to avoid to use the additional 'save' command cause every little editing by the user will be immediately saved which makes using "Discard" impossible.

    I assume I have to use these two functions:

    relshipNode.setAttribute('isDirty', '1');
    relshipNode.setAttribute('action','update');

    But I am not sure which target item to address (top item / relationship items / relationship node or all of them). I tried various variants based on existing code samples, but none of them worked and each time the tab pane crashed when I closed the item.

    Does anyone has experience with this use case?

Reply
  • I made some progress by using this variant:

        aras.setItemProperty(myDocRelations.node,"mycustomprop","mynewvalue"); 

    This will update the relationship property. But I cannot close the main item anymore after edit. The tab pane will crash and I will get the following error message in the browser debugger:

    'factory.js: 74 Uncaught (in promise) CUIError: The command for the command alias 'UnclaimItem' failed. '

    A somehow working variant is the following were I immediately save the changed relationship:

       aras.setItemProperty(myDocRelations.node,"mycustomprop","mynewvalue"); 
       aras.saveItemEx(relshipNode,false);

    But I want to avoid to use the additional 'save' command cause every little editing by the user will be immediately saved which makes using "Discard" impossible.

    I assume I have to use these two functions:

    relshipNode.setAttribute('isDirty', '1');
    relshipNode.setAttribute('action','update');

    But I am not sure which target item to address (top item / relationship items / relationship node or all of them). I tried various variants based on existing code samples, but none of them worked and each time the tab pane crashed when I closed the item.

    Does anyone has experience with this use case?

Children
No Data