Forum Discussion
Former_Member
9 years agoIdeator I
Hi Meismart,
Many thanks for you help.
Yes there is a related Item, it is the child item of the current item (on which the method starts onafteradd) .
I am trying to create a relationship between this child item and another item: the one which represents the root of my product structure.
There can be any number of items of type assembly or othertype between the child item and the root item.
Could you explain me what does this code:
To get the parent item, you can use:
Item parentItem = inn.newItem(“[Parent ItemType]”,”get”);
parentItem.setProperty(“id”,this.getProperty(“source_id”,””) );
parentItem = parentItem.apply();
I do not understand what newItem does when the action is get, are you creating an item or retrieving it? I saw this example many times in the documentation but I am still lost.
Also, in this code, I cannot figure out what you do with the setAttribute method:
//Remember to set the related id of this
Item thisItem = inn.newItem(this.getType(),”edit”);
thisItem.setAttribute(“where”,”id=” + this.getID() +”‘”);
thisItem.setProperty(“related_id”,item.getID());
thisItem = thisItem.apply();
Than you so much for your support
Camille