Home Forums Applications Assign different permissions to a subclass

This topic contains 2 replies, has 2 voices, and was last updated by  coshaughnessy15 1 week, 4 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10377

    coshaughnessy15
    Participant

    Is it possible to assign a different permission set to a subclass itemtype instead of the one used by the base class?

    #10449

    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

    #10451

    coshaughnessy15
    Participant

    This is perfect, thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.