Forum Discussion

hkhan's avatar
hkhan
Creator II
4 years ago
Solved

How can i create new permission and add that in

Hello,

How can i add new permission and add on add

I am using the following mode, it is creating permission but not adding it 

Innovator inn = this.getInnovator();
string docid = this.getProperty("id","");
Item permissions = this.newItem("Permission", "add");
permissions.setProperty("name", docid);
permissions = permissions.apply();
this.setProperty("permission_id", permissions.getID());   
return this;
  • Hi Haider

    I'm able to create permission and attach it to the item. Between which user account are you using ? I tried to use Super User and it is working but it will not work for the normal user as there is no access defined for the permission added. I added creator to the permission which is getting created and provided update access.

    Use below method (onBeforeAdd)

    Innovator inn = this.getInnovator();
    string docid = this.getID();
    Item permissions = this.newItem("Permission", "add");
    permissions.setProperty("name", docid);
    Item access = this.newItem("Access", "add");
    access.setProperty("can_get","1");
    access.setProperty("can_update","1");
    access.setProperty("can_discover","1");
    access.setProperty("can_change_access","1");
    access.setProperty("related_id","8FE5430B42014D94AE83246F299D9CC4");
    permissions.addRelationship(access);
    permissions.setProperty("name", docid);
    permissions = permissions.apply();
    this.setProperty("permission_id", permissions.getID());
    return this;

    Thanks

    Gopikrishnan R

6 Replies

    • haider's avatar
      haider
      Ideator III

      Onafteradd or onbeforeadd server events

      • Gopikrishnan's avatar
        Gopikrishnan
        Accelerator II

        Hi Haider

        I'm able to create permission and attach it to the item. Between which user account are you using ? I tried to use Super User and it is working but it will not work for the normal user as there is no access defined for the permission added. I added creator to the permission which is getting created and provided update access.

        Use below method (onBeforeAdd)

        Innovator inn = this.getInnovator();
        string docid = this.getID();
        Item permissions = this.newItem("Permission", "add");
        permissions.setProperty("name", docid);
        Item access = this.newItem("Access", "add");
        access.setProperty("can_get","1");
        access.setProperty("can_update","1");
        access.setProperty("can_discover","1");
        access.setProperty("can_change_access","1");
        access.setProperty("related_id","8FE5430B42014D94AE83246F299D9CC4");
        permissions.addRelationship(access);
        permissions.setProperty("name", docid);
        permissions = permissions.apply();
        this.setProperty("permission_id", permissions.getID());
        return this;

        Thanks

        Gopikrishnan R