Vadim Tabakman

Nintex Workflow - Iterate and Start a Workflow

I have found that many people are interested in not only starting a workflow as soon as a document or list item is created, but also to run a workflow over a number of items in another list or document library.

You have 2 options here.
1. Create a workflow that performs all the logic for each item in the workflow.
2. Create a workflow that iterates through each item in a destination list/doclib and starts a workflow off for that item.

To do this, I'm going to create a hidden list that will contain workflows I have created and will run on a scheduled basis. To be fairly obvious, I'm going to name this list List For Scheduled Workflows.

My destination list that I want to start workflows on will be named Random Items. In Random Items, I have created a Yes/No field named "Processed", so that my workflows will know whether there needs to be work done.



Now I'll create a workflow, where for this example, all I am going to do is set the Processed field to Yes for the item the workflow is running on.



We now jump back to my List For Scheduled Workflows and create a workflow that will run periodically, query the destination list, and start child workflows.

The first thing we need are the Nintex Workflow variables.
1. collListItemIDs - Collection variable that will contain all the items for the items in the destination list that have not yet been processed.
2. listItemID - this will be used in our For Each loop. As we iterated through the loop, this variable will contain the List Item ID we are up to.

If you want to see how to use the collection variable, please read this : Nintex Workflow - Collection Variable



I'm not going to bother with the Error Handling in this workflow, so that we keep it small, but if I was going to put this type of workflow into Product, I would definitely enable Error Handling.

Now that we have our Workflow Variables, our workflow itself will be quite simple :
1. Query the destination list of unprocessed items
2. Loop through the results of that query
3. Start a Workflow on each unprocessed item



Query List
Here we want to query our destination list for all items that have a Processed field set to No (they haven't been processed yet), and we want to get back the ID of each item. The reason we want to get the ID, is because that is unique for all items in a list, and this will let us start a workflow on each specific item.


For Each
We now go through our collection variable "collListItemIDs", and through each iteration, we store the Item ID in our variable "listItemID".


Call Web Service
Now that we have the List Item ID we want to run the workflow on, we can utilize the Nintex Workflow web service, and specifically the StartWorkflowOnListItem.

All the Nintex Workflow Web Service methods are described in the Nintex Workflow SDK.

We configure the Call Web Service action to call the StartWorfklowOnListItem web method, and give it the List Item ID (our listItemID variable), the List Name (Random Items), and the workflow we want to run (Process Random Item Workflow).


Testing this Process
Once the workflow is published, we can test it out.

From the screenshot below, you can see that my Random Items list has 3 items, all of which have a Processed field set to No.


Moving back to my "List for Scheduled Workflows" list, I haved added a dummy item as in the future (not this article) I will be creating a scheduled workflow here.


I can now start my workflow off on this item.


As this workflow doesn't do very much but start workflows off on other items asynchronously, the workflow itself is quite fast. When we go and look at the "Random Items" list, we see that all the items now have their Processed field set to Yes. Also we see that the "Process Random Item Workflow" status column is also set to "Complete", so we can be sure the workflows we started all worked.

Downloads

Nintex Workflow 2007

Download the Scheduled Process Random Items Workflow  - Download and import into the Workflow Designer page

Download Process Random Item Workflow - Download and import into the Workflow Designer page

Posted by Vadim Tabakman Sunday, February 5, 2012 9:56:00 AM Categories: Call Web Service Collection Variable Error Handling Iterate Nintex Nintex Workflow StartWorkflowOnListItem
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Tuesday, October 22, 2013 10:35:29 AM
Joe

re: Nintex Workflow - Iterate and Start a Workflow

Hello Vadim,

Any idea why a Service Account would work on some workflows, but not others? We have a number of workflows that use StartWorkflowOnListItem that work successfully on SharePoint 2010, Nintex 2010 (latest build). I created one yesterday that keeps giving me this error:

"Failed to invoke web service. Error returned from server: <soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---&gt; Item does not exist. It may have been"

I checked everything, and tried numerous ways to troubleshoot this. I finally used my login instead of the Service Account, and it worked! I changed it back and it failed, so the Service Account is the issue.

Any ideas?

Thanks

Monday, December 23, 2013 12:49:04 PM
Agustin

re: Nintex Workflow - Iterate and Start a Workflow

Dear Vadim,

I have read this page and also this post http://connect.nintex.com/forums/32901/ShowThread.aspx#32901 because I am trying to schedule a workflow to be run every day over all the items on a list, but when I test the Web Service I receive the following error:

<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---&gt; Cannot find list.

Parameter name: listName

Actual value was Certificados.</faultstring><detail /></soap:Fault>

The list exists, and I also tried with the GUID and the URL, but I always receive the error.

Do you know what can be making this happen?

Regards,

Monday, December 23, 2013 1:08:40 PM

re: Nintex Workflow - Iterate and Start a Workflow

Hi Agustin,

that usually happens, if the url you are pointing to is pointing to the wrong site.

If your list exists in http://mycompany.com/finance, then you url to the web service should be http://mycompany.com/finance/_vti_bin/NintexWorkflow/Workflow.asmx

if you don't include the subsite in the url, then the web service call will run in the context of the root site, not the subsite and therefore won't find your list.

cheers,

Vadim

Monday, February 3, 2014 6:52:19 AM
Lukas Parzinger

re: Nintex Workflow - Iterate and Start a Workflow

Hi Vadim,

 

thanks for your last reply - had the same problem like Agustin and your answer to his question also resolved my problem! :)

 

Regards,

Luka

Tuesday, February 11, 2014 11:32:17 PM
shardul Pasare

re: Nintex Workflow - Iterate and Start a Workflow

Hi,

I require to start nintex workflow on multiple items from custom page. If only one item is selected it works as expected. Below is the implementation for this. I am generating below url dynamically to achieve this.

Response.Redirect(base.Web.Url + "/_layouts/NintexWorkflow/StartWorkflow.aspx?list={" + this.List.ID + "}&ID=" + ItemId + "&TemplateID={" + associationId + "}&Source=" + this.List.DefaultViewUrl)

so is there any way that I can select multiple items and run nintex workflow

Thanks in advance

Shardul Pasare

 

Wednesday, May 14, 2014 2:52:39 PM
Kim LeRoy
Gravatar

re: Nintex Workflow - Iterate and Start a Workflow

Hi thanks for the article. I am getting an error that I can't get past. I am using SP2013 if it makes a difference.

<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Client</faultcode><faultstring>Server was unable to read request. ---&gt; There is an error in XML document (1, 307). ---&gt; Input string was not in a correct format.</faultstring><detail /></soap:Fault>

My inputs are as follows:

itemid(int) ListItemID
listname (string) Administration
Workflowname (string) Backup

 

 

 

Tuesday, July 15, 2014 2:26:49 PM
Norman Belen
Gravatar

re: Nintex Workflow - Iterate and Start a Workflow


Hi Vadim,

Thank you, your article helped me a lot.

Saturday, August 30, 2014 8:10:19 AM

re: Nintex Workflow - Iterate and Start a Workflow

Hi Vadim

I have followed your post through to the point where it is then tested, but am having problems getting the workflow created to update the processed column to yes to run. I have checked the web url as discussed in your post to Agustin and also checked that the permissions for the sub site and the list itself are inherited from the parent but to no avail. I am not getting any error messages, presumably because the workflow in the form library is not being run.

Any suggestions, running SharePoint 2007 and Nintex 2010

Saturday, August 30, 2014 10:56:19 AM

re: Nintex Workflow - Iterate and Start a Workflow

Hi Kieth,

If you're using the Call Web Service to start the other workflow, store the result in a text variable and also capture the error in another text variable.  Then add those to a Send Notification action and send them to your email.  There may be something there that tells why the child workflow isn't starting.

Also, make sure your url to the web service contains the site url where the list is where you're trying to start the workflow.

eg. If your list is "Expenses" and it lives in http://mycompany.com/sites/Accounting/Finance

then the url to the web service is:

http://mycompany.com/sites/Accounting/Finance/_vti_bin/NintexWorkflow/Workflow.asmx

cheers,

Vadim

Saturday, August 30, 2014 12:01:38 PM
Kieth
Gravatar

re: Nintex Workflow - Iterate and Start a Workflow

Hi Vadim

Not sure what happened here but I downloaded your workflow rather than use the one which I created from following your blog and it has worked perfectly - thanks very much

Kieth

Saturday, August 30, 2014 12:25:13 PM

re: Nintex Workflow - Iterate and Start a Workflow

Hi Kieth,

 

glad you got it working.

 

vadim

Tuesday, October 3, 2017 7:30:40 AM

re: Nintex Workflow - Iterate and Start a Workflow

Hi Vadim:

I am getting the same error that Agustin reported almost four years ago: "Exception calling "StartWorkflowOnListItem" with "4" argument(s): "Server was unable to process request. ---> Cannot find list."  I have confirmed that the url I'm using points to the site that contains the list and that the list name is correct. I have checked this many times.  In fact, I can verify that the list exists in this site as follows:

  $web = Get-SPWeb $url
  $lists = $web.Lists
  $list =$lists["PowerShellTests"]
  $list.Title
  PowerShellTests
 

Yet, when I run the script I with this $url I still get the above error. Is there anything else that could cause this?

Thanks,

Bruce

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (279)
  • Comments (1769)

Categories