Home Forums Applications Assign different permissions to a subclass

Ce sujet a 3 réponses, 3 participants et a été mis à jour par  petercwc, il y a 10 mois et 1 semaine.

4 sujets de 1 à 4 (sur un total de 4)
  • Auteur
    Messages
  • #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

    Jillian Jakubowicz
    Modérateur

    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!

    #10627

    petercwc
    Participant

    Why it cannot be done using standard Aras UI?

4 sujets de 1 à 4 (sur un total de 4)

Vous devez être connecté pour répondre à ce sujet.