Forum Discussion
jjakubowicz
9 years agoCreator II
Hi,
You can set permissions on a subclass using OnBeforeAdd and OnBeforeUpdate server events on the desired item.
You should be able to use the same method for both events.
In the method, check to see if the item has been set to a certain subclass.
If so, set the permission.
Below is some example code to get you started:
Innovator inn = this.getInnovator();
Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM");
bool PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity);
try
{
if (this.getProperty("classification", "") == "Assembly") {
Item permission = this.newItem("Permission", "get");
permission.setProperty("name", "Assembly Part");
permission.setAttribute("select", "id");
permission = permission.apply();
if (permission.isError()) {
return inn.newError("Could not obtain Assembly Part permission. " + permission.getErrorDetail());
}
if (this.getProperty("permission_id") != permission.getID()) {
this.setProperty("permission_id", permission.getID());
}
}
}
finally
{
if (PermissionWasSet) Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity);
}
return this;
Hope this helps :)
Jillian