cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

AddPermissionsCollection dynamic creation of permissionsInfoXML string

Jump to solution

I need to dynamically add user permissions to a site. I will be using the AddPermissionsCollectionWebService: https://msdn.microsoft.com/en-us/library/websvcpermissions.permissions.addpermissioncollection.aspx

e.g.

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

  <soap:Body>

    <AddPermissionCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">

      <objectName></objectName>

      <objectType>Web</objectType>

      <permissionsInfoXml>string</permissionsInfoXml>

    </AddPermissionCollection>

  </soap:Body>

</soap:Envelope>

Essentially I need to build a dynamic XML string that would look something like this:

<Permissions>

<Users>

<User LoginName="i:0#.f|membership|test1@test.net" Email=test1@test.com" Name="Test 1" Notes="Notes" PermissionMask="1011030767"/>

<User LoginName="i:0#.f|membership|test2@test.net" Email="test2@test.com" Name="Test 2" Notes="Notes" PermissionMask="1011030767"/>

<User LoginName="i:0#.f|membership|test3@test.net" Email="test3@test.com" Name="Test 3" Notes="Notes" PermissionMask="1011030767"/>

</Users>

</Permissions>

For the purposes of my current requirement, the permissions are the same for each user.

The users will be fetched from a Group/Person field in a list which will allow for multiple select (this field will be copied to a string variable as I don't seem to have the option to evaluate Person/Group field "is not empty"??). This field is not required, so this field could have 0,1 or many users assigned to it. I think the Run If command could be used, and must only run if the string var is not empty.

I'm would like some advice on how to build the dynamic list of users.

I have looked at some Nintex documentation on the internet: Tutorial: Adding users to a new team site: How to create a site then provision its users using a workflow

However it seems that O365 is missing the ItemProperty functionality which is critical to this examples implementation - is this true?

I know that I can get the users info by reading the ListItem Field and could use this to build the string, but I'm not sure how I would handle looping though the people assigned to the field...and also wonder if this is the best design approach.

Nintex_SelectReturnType.png

My Requirement is not exactly the same as I need to concatenate the PermissionMask to each user's meta data.

Discussion/thoughts are welcome. I'm sure this problem has been solved before

Message was edited by: Duane Stavropoulos (fixed typo in email address)

Labels: (1)
0 Kudos
Reply
2 Replies
Workflow Hero

Re: AddPermissionsCollection dynamic creation of permissionsInfoXML string

Jump to solution

Hi Duane Stavropoulos,

You can use some combination of action to achieve the build a dynamic XML string.

1. Set Workflow Variables A = "<Permissions><Users>"

2. Set Workflow Variables B = "</Users></Permissions>"

3. Query List - Get Person/Group field (multiple selection) from list

4. Since mutiple selection is set for Person/Group field, the returned value to "person_group_variable" could be

     --> [ ["i:0#.f|membership|admin@test.com"], null, ["i:0#.f|membership|user@test.com","i:0#.f|membership|admin@xxx.onmicrosoft.com"] ]

5. Use For each action twice in to get the account value

     a. For each

     --> Target dictionary = "person_group_variable"

     --> Output = "coll_variable" (dictionary or collection variable type)

     b. For each

     --> Target dictionary = "coll_variable"

     --> Output = "pg_variable" (Person or Group variable type)

    c. Build String

     --> String = "{Variable:C}‍<User LoginName="‍{VariableSmiley Tongueg_variable}‍" Notes="Notes" PermissionMask="1011030767"/>"

     --> Output = C (Text Variable type)

6. To build the final dynamic string, Build String = A + C + B

0 Kudos
Reply
Not applicable

Re: AddPermissionsCollection dynamic creation of permissionsInfoXML string

Jump to solution

Hi KuanChiang Lui​, Thanks for the six steps to success

0 Kudos
Reply