permissions error when trying to create a relationship

Former Member
Former Member
Dear Community, I am new to Aras and am trying to create a relationship from a RelationshipType with the following code:
Innovator inn = this.getInnovator();
string ItemId = this.getID();
Item item = inn.getItemByKeyedName("GivenItem", "100013-001");
string itemfather = item.getID();
if(item == null)
{
return inn.newError("No given item found.");
}
else
{
Item relItem  = inn.newItem("GivenRelationship","add");
relItem.setProperty("source_id",ItemId);
relItem.setProperty("related_id",itemfather);
return relItem.apply();
}
return this;
The method runs onAfterAdd on a relationship ItemType server event. I do not know how to solve this error which comes with the apply() method: "You have insufficient permissions to perform 'add' operation." I am also looking for a way to retrieve the GivenItem item because we dont know its keyed name. What I want to do is to retrieve the Item of type OtherType which has a relation whith the item of type GivenItem (there will be only one each type). Is there a method which permits to get the only item of a given type? Best regards, Camille
Parents
  • 1.MyMainItem.SetRelatedItem(myRelatedItem) takes an Item as single argument it will find(or create) the related_id property in MyMainItem and appends myRelatedItem to it 2.MyMainItem.CreateRelatedItem("myItemType","get") takes a type of item and an AML action as arguments it will find(or create) the related_id property in MyMainItem and appends : "<Item type='myItemType' action='get'/>"
Reply
  • 1.MyMainItem.SetRelatedItem(myRelatedItem) takes an Item as single argument it will find(or create) the related_id property in MyMainItem and appends myRelatedItem to it 2.MyMainItem.CreateRelatedItem("myItemType","get") takes a type of item and an AML action as arguments it will find(or create) the related_id property in MyMainItem and appends : "<Item type='myItemType' action='get'/>"
Children
No Data