Skip to content

Instantly share code, notes, and snippets.

@AngelaIp
Created June 24, 2019 06:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AngelaIp/eadc237ae3369fc90f7002f439c39735 to your computer and use it in GitHub Desktop.
Save AngelaIp/eadc237ae3369fc90f7002f439c39735 to your computer and use it in GitHub Desktop.
Resets specific properties after copying a part
Innovator inn = this.getInnovator();
string id = this.getProperty("id");
// Check if Goal relationships are available;
Item goals = this.newItem("Part Goal","get");
goals.setProperty("source_id",id);
goals.setAttribute("select", "id");
goals = goals.apply();
// 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
{
if (!goals.isError())
{
int count = goals.getItemCount();
for (int i = 0; i < count; i++)
{
Item goal = goals.getItemByIndex(i);
goal.setAction("edit");
goal.setProperty("actual_value", "0");
goal.setProperty("target_value", "0");
goal.setProperty("estimated_value", "0");
goal.setProperty("goal_comments", null);
goal = goal.apply();
}
}
// reset default values in Part
this.setAction("edit");
this.setProperty("my_erp_number", null);
// add additional values....
this.apply();
}
finally
{
// Revoke 'Aras PLM' permissions
if (PermissionWasSet)
Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity);
}
return this;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment