Forum Discussion

hkhan's avatar
hkhan
Ideator I
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  [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:b254bcb3-f5a7-4a5f-...
  • Gopikrishnan's avatar
    Gopikrishnan
    4 years ago

    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