Stronger Together - Nintex Workflow Cloud & Office 365

  • 18 January 2017
  • 2 replies
  • 18 views

Stronger Together - Nintex Workflow Cloud and Nintex Workflow for Office 365. Many of us have been asking for feature such as scheduled workflow in Sharepoint for Office 365, that has not made available by Nintex Workflow for Office 365 today. Well, a scheduled workflow is pretty straight forward and easy to setup in Nintex Workflow Cloud, we can create a scheduled workflow in Nintex Workflow Cloud to trigger a workflow in Sharepoint for Office 365. That gives us the solution of scheduling a workflow in Sharepoint for Office 365.

 

To demonstrate how that works,

 

Nintex Workflow for Office 365 - Site Workflow

1. I have created a Site Workflow in Sharepoint for Office 365 environment. Here is how "MySiteWorkflow" looks like in Nintex workflow for Office 365 environment:

 

2. The "MySiteWorkflow" takes one Initiation Variable as defined below, when the workflow started manually, it will prompt users with the initiation form for users to provide input for the "listname" initiation variable. 

 

3. I have made the Site Workflow as simple as possible, with only only one "Log to History List" action. When triggered, it will simply write the provided "listname" variable value to the workflow history.

 

Nintex Workflow Cloud

While waiting for the Sharepoint Connectors to be released in Nintex Workflow Cloud, I have workaround with Azure AD App for Nintex Workflow Cloud to access the Sharepoint for Office 365 environment via the OAuth 2.0 authentication. For those who have not followed my blog on that, here is the link you could refer to on Add Azure AD App from Azure Portal section of the blog post. (Please take note that, instead of using https%3A%2F%2Fgraph.microsoft.com%2F as the value for the resource parameter, I have this time to use <site_host>@<site_reaml instead, as such my example i was using resource=https%3A%2F%2Fntxte07.sharepoint.com@<site_rearm> instead.)

 

1. Instead of creating a Scheduled Workflow, let us try to call the Sharepoint site workflow from Nintex Workflow Cloud using a Public Web Form start event to start the workflow in Nintex Workflow Cloud, the start event is configured as below to capture the input to be used as "listname".

 

2. Before we proceed to define other actions, lets look at the list of workflow variable we will need to create for the workflow to work.

 

3.  Using "Set a variable value" action to assign the Access Token we obtained to the "accessToken" variable as shown below.

 

4. With the "accessToken" assigned, we going to add a "Branch by Stage" with two branches, one being the normal path to follow, the other to handle if the Access Token is expired, to renew the Access Token. I have named it as "Branch 1" and "Branch 2" as shown below

 

5. We set the branch to always start from "Branch 1" assuming the token is valid, by calling a "Call a web service" action to call Sharepoint online's REST API. To start a workflow in Sharepoint online, we will need to, first, get the workflow's subscription ID, followed by initiate the workflow to start. Define the "Call a web service" with the following values:

Field Value
URL https://<YourTenantName>.sharepoint.com/_vti_bin/client.svc/ProcessQuery
Request Type HTTP Post
Request Headers
Authorization: Bearer accessToken
X-Requested-With: XMLHttpRequest
Request Content
Request Content example:
 
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="Javascript Library">
<Actions>
<ObjectPath Id="1" ObjectPathId="0" />
<ObjectPath Id="3" ObjectPathId="2" />
<ObjectPath Id="5" ObjectPathId="4" />
<ObjectPath Id="7" ObjectPathId="6" />
<ObjectPath Id="9" ObjectPathId="8" />
<Query Id="10" ObjectPathId="8">
<Query SelectAllProperties="false">
<Properties>
<Property Name="PropertyDefinitions" SelectAll="true" />
</Properties>
</Query>
</Query>
</Actions>
<ObjectPaths>
<StaticProperty Id="0" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /><Property Id="2" ParentId="0" Name="Web" />
<Constructor Id="4" TypeId="{4ccc7f0e-bf7e-4477-999c-6458a73d0039}">
<Parameters>
<Parameter ObjectPathId="2" />
</Parameters>
</Constructor>
<Method Id="6" ParentId="4" Name="GetWorkflowSubscriptionService" />
<Method Id="8" ParentId="6" Name="GetSubscription">
<Parameters>
<Parameter Type="String">[Workflow Template ID]</Parameter>
</Parameters>
</Method>
</ObjectPaths>
</Request>
Response Content resContent
Response Headers resHeader
Response Status Code resCode

 

[Workflow Template ID] = e.g. {9CE443B7-3583-46C2-AA07-415F5E00C25B}, could be found from the site workflow start page's workflow link as shown

 

6. Verify if the "Call a web service" is successful by using the "Branch by condition" to check the "resCode" equals to 401, if yes we will change the stage to "Branch 2" for getting new Access Token with the "Refresh Token" obtained during the steps setting up the "Azure AD App". We will follow the "No" path if the resCode returns status code other than 401 (i.e. with the assumption the call to get the workflow subscription is successful).

 

 

7. The "Query JSON" followed by the "No" path is basically to get the returned the "_ObjectIdentity_" value with XPath search of "$.._ObjectIdentity_" from the resContent JSON object. The "_ObjectIdentity_" to be used in the following "Call a web service" action.

 

8. "Call a web service" with the following details to initiate the site workflow

Field Value
URL https://ntxte07.sharepoint.com/_vti_bin/client.svc/ProcessQuery
Request type HTTP Post
Request headers
Authorization: Bearer accessToken
X-Requested-With: XMLHttpRequest
Request content

My "Request content" example: (I would advise to use fiddler to capture a manual trigger of your site workflow in Sharepoint online, and capture the two HTTP POST to https://<your site host>/_vti_bin/client.svc/ProcessQuery  for the XML request body to be used as your Request content here).

 

<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="Javascript Library">

<Actions>

<Method Name="GetExternalVariable" Id="12" ObjectPathId="8">

<Parameters>

<Parameter Type="String">listname</Parameter>

</Parameters>

</Method>
<ObjectPath Id="14" ObjectPathId="13" />
<Method Name="StartWorkflow" Id="15" ObjectPathId="13">

<Parameters>

<Parameter ObjectPathId="8" />
<Parameter Type="Dictionary">

<Property Name="listname" Type="String">List Name</Property>
<Property Name="Microsoft.SharePoint.ExternalVariable.listname" Type="String">List Name</Property>

</Parameter>

</Parameters>

</Method>

</Actions>
<ObjectPaths>

<Identity Id="8" Name="subscriptionID" />
<Method Id="13" ParentId="4" Name="GetWorkflowInstanceService" />
<Constructor Id="4" TypeId="{4ccc7f0e-bf7e-4477-999c-6458a73d0039}">

<Parameters>

<Parameter ObjectPathId="2" />

</Parameters>

</Constructor>
<Property Id="2" ParentId="0" Name="Web" />
<StaticProperty Id="0" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />

</ObjectPaths>

</Request>

Response content resContent
Response headers resHeader
Response status code resCode

 

That shows the second web service call to trigger the site workflow to start.

 

9. Continued from step 4 above branching to "Branch 2" is the same steps in my blog post on the "Azure AD App" setup on how to refresh the access token by calling the REST end point at "https://login.microsoftonline.com/common/oauth2/token" as shown below.

 

10. The "Query JSON" is to use XPath to search to the access token from the resContent returned from the above action call, and assign the new access token to the accessToken workflow variable.

 

The above steps demonstrate both the site workflow in Sharepoint for office 365 and the Nintex Workflow Cloud to manually trigger the site workflow in Office 365 to run. With that testing successful, we know we could now schedule a site workflow in Sharepoint for Office 365. To do that, we just need to schedule the Nintex Workflow Cloud using the Nintex connector with start Event of "Scheduled Start" as shown in the screen captured below as an example.


2 replies

Badge +9

wicked post ‌ certainly prompts me to think about alternate ways of getting things done

Badge +8

Yet another great post! (I am cathing up on my readings)

Reply