michelle
8 years agoCreator II
Update Parents Item
Hi
I create item "ATEN_VPN" add relationship "ATEN_VPN_File".
When I save ATEN_VPN I need to know how many count in "ATEN_VPN_File" and save in ATEN_VPN
In ATEN_VPN Server Event "onBeforeUpdatae" add this method
Code:
Innovator innovator = this.getInnovator();
ArasTool aras = new ArasTool(innovator);
string formName=this.getType();
string formId = this.getID();
Item formItem = innovator.newItem(formName,"get");
formItem.setID(formId);
formItem=formItem.apply();
formItem.fetchRelationships("ATEN_VPR_File");
Item relationships = formItem.getRelationships("ATEN_VPR_File");
int count = relationships.getItemCount();
formItem.setProperty("_h_test",count.ToString());
formItem=formItem.apply("edit");
return this;
-------------------------------------------------------
But apply will show error message:An item with the same key has already been added.
I don't know why.