Conditionally Delete Site In SharePoint 2016 Using Nintex Workflow 2016

SharePoint 2016 general availability had been announced in the Future Of SharePoint conference in May 2016. The series, which discusses the installation of SharePoint 2016 in Azure can be found at C# Corner from the links, given below:

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.

We have earlier explored how to create a site, using Nintex Workflow 2016 by entering the Site 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 site. You can read the Site Provisioning 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 ‘Site Creation’ 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 Site’ column value to ‘Yes’, we will invoke a Nintex 2016 Workflow to delete the Site. This mechanism can be used to implement the site retention.

implement site

The scope of the article will be:

  • Modify the list item column to trigger Workflow.
  • Delete the Site, based on the value of the column ‘Delete Site’.

Let’s go ahead to the primary list, where we will be running our Nintex Workflow. In our case, it is the ‘Site Creation’ List. Select ‘Create a Workflow in Nintex Workflow’.

Create a Workflow in Nintex Workflow

This will open up the 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 Site ?’) == ‘Yes’

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

Run If

Once the Run action is added, it will show the condition missing warning.

warning

Click 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 site should be deleted, if the column value is ‘Yes’.

Yes

Now drag and drop the ‘Delete Site’ option on to the designer.

Delete Site

Once the action is dropped on to the designer, it will show the warnings of the missing configuration.

warnings

It clearly states that the parent site and URL name is missing. Click the action drop down menu and select ‘Configure’ option.

Configure

This will open up the page, where we can configure the delete site action.

action

Select the parent site by browsing to the site by clicking ‘Select team site’ link.

Select team site

This would select the parent site. Now, we have to enter the URL of the site, which has to be deleted. This should not be hard coded as our purpose is to automate the site deletion by retrieving the details of the site to be deleted from the list item upon its update. Thus, click the browse button next to URL Name field and select the list item field ‘Site URL’ from Item Properties tab.

Site URL

The override credentials can be specified to perform impersonation, which is not necessary, unless intended. Thus, the form will look, as given below. Click Save to update the site deletion information.

Site URL

Click Workflow settings, as we have to set the Workflow starting condition.

Workflow settings

Ensure that the starting condition ‘Start when items are modified’ is set to ‘Yes’. Click Save to update the Workflow settings.

Start when items are modified

Now Publish the Workflow to the list.

Publish

Specify the Workflow name, description and Submit.

description

It will start publishing the Workflow. 

publishing

The Workflow has been successfully published.

published

The Workflow form will look like:

workflow form

Now, let’s go ahead to the list. It will have a new column called ‘Site Deletion Workflow’, which will display the status of the Workflow, once it is triggered.

Site Deletion Workflow

Edit the list item and set the ‘Delete Site ?’ column to Yes by selecting the Checkbox. This will trigger the site deletion Workflow.

Delete Site

The Workflow has been triggered and it has run to completion. Thus, the workflow has deleted the site, based on the item update, which happened in the list.

new

Summary

Thus, we saw, how we can conditionally delete the SharePoint 2016 site, using Nintex Workflow 2016, based on the update in a SharePoint List Item. These workflows can be used to monitor site retention, using a single SharePoint configuration list.