Function removePermission javascript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2015 06:25 AM
I need to change permissions on all my nodes using a script. The setPermission function is working good like this :
<blockcode>
node.setPermission("permission", "GROUP_groupname");
</blockcode>
But i need to remove all the old permissions on all the nodes too, so before setting new permissions, i try to erase all the old ones thank to removePermission, without user or group parameter, as explained in the documentation :
<blockcode>
node.removePermission("permission");
</blockcode>
But it's not working. I used another method which is working good :
<blockcode>
var permissions = ["Collaborator", "Contributor", "Consumer", "Editor", "Coordinator", "Read"];
var groups = ["GROUP_groupe1", "GROUP_groupe2", "GROUP_groupe3", "GROUP_groupe4", "GROUP_groupe5"];
for(var z= 0; z < permissions.length; z++)
{
for(var w= 0; w < groups.length; w++)
{
node.removePermission(permissions[z],groups[w]);
}
}
</blockcode>
But i need to understand. I think i miss understood this function. For me, using removePermission without precising a group or user, erase ALL the permission selected for all the users or groups in the selected node. Am I right ?
Does someone can explain to me please ?
Thank you
Anthony
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 04:44 PM
hi! did you find a solution for this ?
Regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 09:20 PM
I have not tested it myself, but reading the documentation, I noticed a small detail, that can be the reason it is not working the way you want it.
removePermission | Alfresco Documentation
The first variation:
removePermission(permission)
removePermission(permission) removes a permission for all users from the node.
The second one:
removePermission(permission, authority)
removePermission(permission, authority) removes a permission for the specified authority (for example, a user name or group) from the node.
So, it seems the first one is intended to be used with users only, and the samples you showed are all groups.
