In some instances it may be necessary to increase performance by using a Call Web Service action to speak to another workflow.
Extremely large workflows can be difficult to edit and may run slower than a smaller workflow designed for a specific process. In these cases, splitting the workflow into separate workflows and having the first workflow call the second and so on can increase performance.
This can also be an advantage if there is an error; the workflow can be restarted from a certain point rather than from the beginning.
The Start Workflow action allows the user to start a workflow on the same list item only. This is useful in certain situations but more often than not starting workflows on different list items is required. Also, if the workflows are part of a larger process, passing variables between the workflows is essential. This can be achieved using the Call web service action and web service methods.
This tutorial will guide you through starting a workflow using the Call Web Service workflow action and the web service methods StartWorkflow and StartWorkflowOnListItem. Using these methods, workflows can be started on different lists and items.
There will also be examples of how to correctly use start data and the format required.
The Call Web Service action allows the workflow to make a call to a SOAP web service method. This action can be used to call any web service. It is commonly used to call the SharePoint web services (http://msdn.microsoft.com/en-us/library/cc752745.aspx) to interact with list items in other sites, or call custom web services that perform processing external to the workflow.
This first section will demonstrate how to use the StartWorkflow web service within a Call Web Service workflow action, this is an example of a workflow action, not a step-by-step workflow tutorial. The StartWorkflow web service starts a workflow on an item in a document library, where the file URL of the document is known.
Note: This section demonstrates how to configure a Call web service action and is not part of a workflow.
Note: This field may be left blank as there is no start data.
The StartWorkflowOnListItem web service method should be used if a workflow needs to be started on a list item directly or the item URL is not known.
This Call Web Service action can then be added to any other workflow in your SharePoint site to start the selected workflow; in my example I will use a workflow titled testworkflow01.
We will configure the Call web service action as in the previous section and instead select StartWorkflowOnListItem as the web service method.
Note: This field may be left blank as there is no start data.
The workflow I am using is called Testworkflow01 and the list is in the image below.
I want to start a workflow on this item so I would configure the Web service message as:
Click Save.
We now know how to configure the Call Web Service workflow action with two different web methods. Another requirement may be to pass certain workflow variables between workflows when they are part of a larger process.
To do this, we must populate the target workflow with start data. These start data variables can then automatically be populated when the workflow is started. The first step is to create a simple workflow with start data configured.
A Log in History List workflow action can be added to the workflow to log the values of these variables and test whether they were correctly set.
To test starting a workflow with these variables, automatically set when the workflow starts either of the web service methods listed in this tutorial can be used.In this example, the StartWorkflowOnListItem method will be used.
To begin, a dynamic string action must be built to create the associationData XML required in the Call Web Service action. We will use this action to create an association data variable, adata.
The format for the association data parameter is as follows:
<Data>
<StartDataItem1>value1</StartDataItem1>
<StartDataItem2>value2</StartDataItem2>
<StartDataItem3>value3</StartDataItem3>
</Data>
The workflow we are attempting to start has two Start Data items texta and Number1. Therefore, the association data will be as follows:
<Data>
<texta>testvalue1</texta>
<Number1>12345</Number1>
</Data>
This will set the variable ‘texta’ to testvalue1 and ‘number1’ to 12345. Create the association data variable.
The two start data variables, texta and number1 have now been combined into the one association data variable.
The association data can now be added to the Call Web Service action.
There may be a case where a common process workflow will need to be run on all existing items in a list/library, not only a single item. To achieve this, we must first query all the items within a list and then loop through this result. Within the loop, the current item will be passed to the StartWorkflowOnListItemID web service method. Use the ‘StartWorkflowOnListItemID’ method to start a workflow on each item within a list or library. This will in turn start the workflow on that item.
This type of workflow can be executed once on any item within the list and will then trigger the specified workflow to run on all list items.
Two variables are required for the example.
ItemIDcollection
A collection variable used to store the item ID collection from the initial query.
CurrentItemID
This is used within the For Each action to store the current ID being referenced within the loop, the value will also be passed to the Call Web Service action.
The first step is to query all the items in the current list/library and store the resulting IDs within a collection variable. We can do this using a Query List action.
The Query List action will be set to return each item ID in the list (regardless of the values they contain) to be used within a For Each loop. The result is stored in a collection variable. This variable allows for more than a single value to be returned.
Note: In the Filter section, you can select to start the workflow on items which meet a specific criteria; for example, only items with a title field which contains the value ‘red’.
The For Each action will loop through each of the ID values returned, once a collection variable has been populated. The For Each loop will also contain the call web service action that will be starting the target workflow.
The configuration of the web service action is the same as explained in the previous section “Nintex ‘StartWorkflowOnListItem’ web service method example” except that the ID will be the ‘currentID’ variable, which is based on the result of the ‘for each’ loop.
The completed workflow will look like this design.
Start the workflow manually on any item within the target list. This will cause the specified workflow to run on each item based on the query result.
Hi,
I need to develop a workflow which queries a list and send notification to users for Approval/Rejection.
I create a workflow which will query the list and then then in for each loop i used a Call Web Service task to call another workflow which will send notifications to users.
I used a variable in my target w/f as Start Up Variable, the first workflow executes properly and calls the other workflow but the variable passed is always blank.
How, can I get the value of the variable? I used your above approach, but still not able to pass values.
Regards,
Shyam
Hey Shyam, I've created a discussion for you in the Learn More space so more people can view it - Starting a workflow using a web service - how to get the value of the start data variable?
Cheers
Hi,
I have created a list and added a workflow which will be triggered when a item is added to the list. That's working fine. Now, i want to use the same workflow for other list too. So, can i do that ?
Is each workflow associated with only one list ? Do we have global workflows ?
Thanks
Hi!! Good Night,
I need to conoect mi CRM System with a nintex workflow and this offer a web service. I am new in this and need a help. can somebody guide me how to do it ?.
Thanks yo so much!
There is a mistake here. Step 4, appending to the Web URL omits the leading forward slant "/"
The instructions say to append "_vti_bin/NintexWorkflow/Workflow.asmx."
However the instructions should say to append "/_vti_bin/NintexWorkflow/Workflow.asmx" to the Web URL.
Thanks Joe I've corrected step 4.
Cheers!
I am getting error when calling the Web Service. Please advise.
Error - "The remote server returned an error: (500) Internal Server Error."
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://nintex.com">
<soap:Header>
</soap:Header>
<soap:Body>
<m:StartWorkflowOnListItem>
<m:itemId>{WorkflowVariable:currentitemID}</m:itemId>
<m:listName>XXXXX</m:listName>
<m:workflowName>Pull Data</m:workflowName>
<m:associationData>
</m:associationData>
</m:StartWorkflowOnListItem>
</soap:Body>
</soap:Envelope>
Btw, during Step-8 of Call Web Service, I don't get List Name as an option. Instead I have to type in my list name manually. Not sure if it is due to my environment or a different version.
Step - 8 In the listName (string) field, click on the Insert Reference icon and select List Name.
Thank you.
Same problem here. Anyone an idea how to solve?