Microsoft requires that Role ID’s are used when granting permission and although the 10 digit ID’s can be found online, custom permissions are not easily available.
There are two ways to get the Role ID’s
Examine the source code of a raw HTTP statement
After logging into SharePoint, open a Browser window and enter the following after the site name
https://contoso.sharepoint.com/sites/dev/_api/web/roledefinitions
A screen similar to the one below will be displayed.
Select View>Source as shown above and the raw data of the request will appear in a window similar to the following
This represents the raw data returned by the call. You can search for your Permission Level within this viewer, or you can paste this data into an XML Viewer as I have done first, which makes for an easier search as shown in the following image
Actually, this is not much better, but in the highlighted section, you can see that the Role ID for ‘Full Control’ is 1073741829. Now you have your role ID
Execute a REST call directly from the Workflow
Alternatively, you can execute a REST call directly from the workflow to get a role ID of a particular permission level. The complete statements are shown below and then broken down after this image
Set a string variable to the name of the permission level whose Role ID you require.
In this case I am looking for the ‘Full Control’ Role ID
Define the REST call string
Set String01 to the following
[%Workflow Context:Current Site URL%]/_api/web/roledefinitions([%Variable:String02%])
This statement will get the ‘single’ role ID for the values defined in ‘String02’ – namely ‘Full Control’
Make the REST call
Insert a ‘Call HTTP Web Serice’ action to make the REST call using the value in ‘String01’ as follows:
Make sure that the Request Headers (accessible via the actions properties) isset to a Header Dictionary that has the name ‘Accept’ set to ‘application/json;odata=verbose‘
Update the Current Item.
This is optional and is not required but I use it so I can query the Response returned by the rest call.
For your edification, the REST call will return the following values (shown in JSON format). You can see that all the attributes of the Role are returned, including the Description, ID and RoleTypeKind
{
“odata.metadata”: “https://jahglobal.sharepoint.com/sites/jkt-dev/_api/$metadata#SP.ApiData.RoleDefinitions/@Element”,
“odata.type”: “SP.RoleDefinition”,
“odata.id”: “https://jahglobal.sharepoint.com/sites/jkt-dev/_api/Web/RoleDefinitions(1073741829)”,
“odata.editLink”: “Web/RoleDefinitions(1073741829)”,
“BasePermissions”: {
“High”: “2147483647”,
“Low”: “4294967295”
},
“Description”: “Has full control.”,
“Hidden”: false,
“Id”: 1073741829,
“Name”: “Full Control”,
“Order”: 1,
“RoleTypeKind”: 5
}
Get the ID of the Role
Use a ‘Get an item from a dictionary’ action to get the ID of the role. This value is stored in the workflow variable ‘ID’ as shown below
You now have the Role ID in the variable ‘ID’