Created
June 24, 2019 06:54
-
-
Save AngelaIp/eadc237ae3369fc90f7002f439c39735 to your computer and use it in GitHub Desktop.
Resets specific properties after copying a part
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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