Check If Group Exists In SharePoint Server 2016 Using Web Service And Nintex Workflow 2016

The series that discusses the installation of SharePoint 2016 in Azure can be found at C# Corner from the below links,

Nintex is a premium technology partner for SharePoint. With the announcement of SharePoint 2016, Nintex has made the announcement of the general availability of Nintex Workflow 2016 on July 11th 2016.

In this article, we will see how to check whether a SharePoint Group exists or not, using Nintex Workflow, based on the list item created in a configuration list. The scope of the article will be,

  • Create a configuration list that will hold the information above the SharePoint Group to be checked for existence.
  • Create an item in the list which will include SharePoint Group Name.
  • Trigger a Nintex Workflow on item creation or modification and check if the SharePoint Group exists with the name as the configuration list item column value. Update the list back with the result.

So, the first step is to create a list with the name, say: SharePoint Group Operations in SharePoint. 

sites

Add the following two columns to the List:

1. SP Group Name – Name of the SharePoint group.

2. Group Already Present? – Create this column to update back the result of the check.

Group

Now, the basic infrastructure is in place. Let’s go ahead and design the Workflow. Click on ‘Create a Workflow in Nintex Workflow’ from the Workflow Settings option.

Workflow

This will open the Nintex Workflow designer. Before adding the Workflow activities, declare 2 Workflow variables which will be used within the Workflow.

 workflow variables

From the Workflow Settings option, click on Variables. It will open the form where we can add new variable.

new variable

Create the first variable of the name ‘SPGroups’. It will hold all the groups within the SharePoint Site collection.

SPGroups

Create a second variable of the name ‘Group already present’ and of type Boolean. It will hold the result of the group existence check.

Group already present

Thus, we have created the required variables.

variables

Now, let’s add the Workflow activity that can be used to check the presence of a group. Add the web service action, as shown below.

web service

The action will show the below warnings as some of the configuration values are missing.

warnings

From the drop down, click on ‘Configure’.

Configure

The configuration page contains the details that will be used for checking the presence of the SharePoint group. In the URL field, add the URL for the usergroup.asmx web service. We will fetch the web URL dynamically and append “_vti_bin/usergroup.asmx” to it, so that a full web service URL is created. From Insert Reference tab, add Web URL.

Configure

Add the site collection administrator credentials which will be used by the Workflow to connect to the web service. Click on Refresh. This will populate the web methods in the drop down.

drop down

The web service URL will be shown in a pop up.

web service URL

Click on OK. Select the web method which will be used to fetch the group collection from the site. Since we are fetching the groups from the site collection, let's go with ‘GetGroupColletionFromSite’. If we have a web with unique permissions and we want to check group existence in that web, we can chose ‘GetGroupCollectionFromWeb’.

GetGroupColletionFromSite

The configuration form, after settings entry, will look as the following. Make sure we specify the Workflow variable ‘SPGroups’ in the field ‘Store results in’. This variable will be used to check group existence.

SPGroups

Now, let’s add a Regular expression activity so as to check the existence of the group .

existence

Click on Configure option to add the condition check in the regular expression activity.

Configure option

Within the ‘Pattern’ field, add the List Column ‘SP Group Name’. This will be the name of the group whose existence we are checking in the site.

SP Group Name

Change the ‘Operation’ to ‘Check match’ and in the field ‘Input text’, add the Workflow Variable ‘SPGroups’.

Check match

Thus, we will be checking if ‘Pattern’ is present in ‘SPGroups’. Store the result of the check, a Boolean value, into the Workflow variable ‘Group Already Present’.

SPGroups

Now, let’s update the value of the condition check back to the list. Drag and drop ‘Update Item’ action on to the designer.

Update Item

Specify the field that we will be updating in the list and the value that will be assigned to it. Here, we will be updating ‘Group Already Present?’ list column with the Workflow variable ‘Group Already Present’.

Group Already Present

The entire Workflow will look like the following image.

workflow

Now, let’s mention when the workflow will run. Select Workflow Settings.

Select Workflow Setting

Specify the Workflow name and description, and set the start conditions ‘Start when items are created’ and ‘Start when items are modified’ to Yes.

Start when items are modified

Go ahead and publish the Workflow.

publish

The publishing of the Workflow has started.

publishing of the workflow

Finally, the Workflow is published.

workflow

Let’s create a list item with the name of the SharePoint Group to check for existence.

list item

A new column by the name of the Workflow has come up in the list and it shows the status of the Workflow. The status is ‘In Progress’ and currently ‘Group Already Present?’ shows the default value’ No’.

Group Already Present

Once the workflow has run to completion, the value of the ‘Group Already Present?’ has changed to Yes. ‘Members’ is an Out of the Box SharePoint group and the workflow has successfully validated the group’s presence.

Members

Conclusion

Thus, we have seen how to check if a security group is present in SharePoint 2016, using UserGroup.asmx web service and Nintex Workflow 2016.

Up Next
    Ebook Download
    View all
    Learn
    View all