Sharepoint 2010 Workflow Change List Column Fire Workflow Again on Edit Loop
Looping Through List Items in SharePoint 2013 Designer Workflows
SharePoint 2013 Designer workflows at present has 2 new interesting options: the ability to call HTTP web services and the option to loop over some code a number of times. This, together with the new REST API, which supports querying lists and returning data in JSON, allows iterating through list items in a workflow, something that was not possible before.
In order to demonstrate this, allow's create a new Site Workflow in SharePoint Designer, that volition iterate through the Tasks listing:
Call it Process Tasks, for case, and make certain you select SharePoint 2013 as the platform type.
In the workflow designer, let's start by creating a new phase, telephone call it Retrieve Tasks:
In information technology, we add together a new Set Workflow Variable action which creates a new Cord variable chosen url with the value "http://sp2013/_api/web/lists/getbytitle('Tasks')/items". This uses the new Residue API, and you tin pass in additional options, such every bit for ordering by the DueDate field in descending order:
http://sp2013/_api/web/lists/getbytitle('Tasks')/items?$orderby=DueDate desc
or filtering:
http://sp2013/_api/web/lists/getbytitle('Tasks')/items?$filter=DueDate gt DateTime'2014-07-31T00:00:00'
or paging:
http://sp2013/_api/web/lists/getbytitle('Tasks')/items?$top=xx
Next, we add together a Lexicon variable (Build a Dictionary action), call it requestHeaders, and initialize it every bit this:
Both "Accept" and "Content-Blazon" entries are of the String type and they both contain the value "application/json;odata=verbose", SharePoint Residual API understands this and sets the response content type accordingly as JSON. If we don't pass these values, the output would come as XML.
Following, add together an Call an HTTP Web Service action and ready its backdrop. The request will be the url variable:
Response content will go to a new variable called responseContent:
Response headers will go to a new variable chosen responseHeaders:
And the same goes for the response code (variable responseCode):
So we fix the asking headers to exist the requestHeaders variable nosotros created just now, by clicking on the properties for the Telephone call an HTTP Web Service action:
Now, create a new stage, call it Process Tasks, and, at the finish of the initial stage, add a Go to Procedure Tasks action.
On the Procedure Tasks stage, add together a Get an Item from a Lexicon action, set the item as d/results, the source variable reponseContent and the output to a new variable of blazon Lexicon called listing. Then count items from this list variable using a Count Items in Dictionary activeness and store the outcome in a new Integer variable called count. This variable will tell us how many times nosotros have to loop. Finally, create a new Integer variable chosen alphabetize and set it to 0 (Fix Workflow Variable), this volition be the loop index.
Next, add a loop (Loop n Times), telephone call it Loop Chore Items, and set the loop variable to count. Within the loop, get value d/results([%Variable: index%]) using a Get an Item from a Dictionary activity from responseContent and store it in a new Dictionary variable chosen item. Become some fields (Get an Detail from a Dictionary) from the item variable, such as Title and DueDate (listen you, these will be task item fields) and shop them in appropriate variables and practise whatever you lot want with them, like logging its contents (Log). Time to increment the loop counter: add together a Do Adding activity and in information technology increment the alphabetize variable into a new Integer variable chosen indexPlusOne. Then set the index variable to exist the indexPlusOne (Set Workflow Variable). Finally, exit the loop and fix the workflow status (Set Workflow Condition action) to Finished. At the end of the stage, select Go to Cease of Workflow.
That's it. Your workflow should look similar this:
The new functionality makes SharePoint Designer workflows much more powerful than before. I will continue to talk about information technology in the post-obit posts.
Source: https://weblogs.asp.net/ricardoperes/looping-through-list-items-in-sharepoint-2013
0 Response to "Sharepoint 2010 Workflow Change List Column Fire Workflow Again on Edit Loop"
Enregistrer un commentaire