Conditionally Delete List In SharePoint 2016 Using Nintex Workflow 2016 And Web Service

SharePoint 2016 general availability was announced at the Future Of SharePoint conference in May 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 general availability of Nintex Workflow 2016 on July 11th 2016.

We have earlier explored how to create a list, using Nintex Workflow 2016, by entering the list Creation Information as a list item in a list. Whenever an item is created based on the item column values, the workflow would create a list. You can read the article from here.

In this article, we will be extending the process. We will be adding one more column to the list ‘Delete Site ?’ which will be a Boolean Yes/No field. The list ‘List Operation’ will contain list items, based on which a site is created when the list item was added to the list. Now, when we modify the existing list item’s ‘Delete List ?’ column value to ‘Yes’, it will run a Nintex 2016 Workflow to delete the list. As a prerequisite, ensure that the column ‘Delete List?’ is added to the configuration list, ‘List Operations’ as a Boolean field.

List Operations

The configuration list along with the columns will look like the image shown below.

configuration

The scope of the article will be -

  • Modify the list item column to trigger the workflow.
  • Delete the list based on the value of the column ‘Delete List?’

Let’s go ahead to the primary list where we will be running our Nintex Workflow. In our case, it is the ‘List Operations’ list.

Select "Create a Workflow in Nintex Workflow".

Workflow

This will open the Nintex Workflow designer.

Nintex Workflow designer

We can select the actions from the left pane. Before selecting the main delete function, let's add the conditional check to the designer i.e.,

If (‘Delete List?’) == ‘Yes’

In order to do that, right click the designer and select the ‘Run if’ condition.

designer

Once the ‘run if’ action is added, it will show the condition missing warning.

warning

Click on Configure button in the action.

Configure

Within the condition specify the column name and the value against which the action should run. In our case, the list should be deleted if the column values is ‘Yes’.

condition

Nintex Workflow does not have an action to delete the list directly from the left pane. We will make use of the SharePoint out of the box Lists.asmx service to implement the list deletion operation. Right click within the ‘Run if’ condition and select "Call web service" option.

Call web service

It will show the missing configuration values in a warning box.

warnings

Click on Configure option to set up the web service.

Configure

The URL option is the primary field that will connect the workflow to the web service.

action

Click on the browse option next to the field and get the current Web URL from ‘Common’ tab.

browse

Append “_vti_bin/lists.asmx” to the Web URL dynamic parameter so as to construct the entire web service URL. Enter the site collection administrator credentials in the authentication fields in order to successfully connect to the web service. Click on ‘Refresh’ button to populate the web methods in the drop down.

URL

Select ‘DeleteList’ as the web method. Now, we have to pass the list name as the parameter to the web service. Click on the browse functionality and get the list item’s ‘List Title’ column value from ‘Item Properties’ tab.

DeleteList

Thus, the web service configuration will look like the image shown below.

configuration

Hovering over the action will show the summary of the workflow activity.

action

Now, let’s set the start condition for the workflow. Click on Workflow settings.

Workflow settings

Specify the workflow name and description. Set "Start when items are modified" field to ‘Yes’ so that the workflow will run on item updated event.

workflow

Let’s go ahead and publish the workflow.

publish

Make any changes to the workflow name and description before the workflow is published.

description

The publishing of the workflow has started.

publishing

Finally, the workflow has been published.

published

Now, let’s go to the list and change the ‘Delete List?’ column to ‘Yes’. This will trigger the workflow and will delete the list by the name in ‘List Title’ column.

List Title

As you can see, the workflow has run and the status has been changed to ‘Completed’ indicating the successful deletion of the list.

List Title

Summary

Thus, we saw how to delete the list conditionally, using web service and Nintex Workflow 2016 in SharePoint Server 2016.

Up Next
    Ebook Download
    View all
    Learn
    View all