Forum Discussion

Wian_le_Roux's avatar
Wian_le_Roux
Ideator III
5 years ago
Solved

Calculate Stock on Order Values

Hi Everyone I have been struggling with creating a server side method for the following scenario I have 2 Item Types and a Relationship between. I would like the value of the Relationship property ...
  • angela's avatar
    angela
    5 years ago

    Some standard code like this should already to it. I would use it for onAfterAdd and Update from your relationship ItemType:

    // Grant 'Aras PLM' permissions
    Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM");
    bool PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity);

    try
    {

    string myId = this.getProperty("related_id");
    Item editItem = inn.getItemById("Part", myId);
    editItem.setAction("edit");
    editItem.setAttribute("doGetItem", "0");
    editItem.setProperty("myproperty","newvalueforproperty");
    editItem = editItem.apply();
    if (editItem.isError())
    {
         return inn.newError("An error occured: " + editItem .getErrorDetail() );
    }
    return editItem;
    }
    finally
    {
    // Revoke 'Aras PLM' permissions
    if (PermissionWasSet)
    Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity);
    }