Dear Dev Talk:
I have a list in SharePoint 2010 that has the following fields:
- Status: Submitted, Under Review, Closed
- Running Days Under Review
I am trying to populate the field 'Running Days Under Review' for all items where a 'Status' = 'Under Review'
1. Site Workflow
a. Query List for Created Date and store in Collection Variable DateCreatedCollection
b. For Each Created Date in DateCreatedCollection (collection variable) store in CreatedDate (date variable)
i. Build string:
- abs(datediffdays(CreatedDate, Today)) and store in RunningDays
ii. Update Multiple Items:
- Filter current list where Created = CreatedDate
- Filter current list where Status = Under Review
- Update 'Running Days Under Review' Field with variable 'RunningDays'
I am getting all items with a status of "Under Review" to update, but the WF is calculating only one date in the collection variable and populating each list item with that one dates RunningDays value. I also tried the 'For Each' action on the ID of the list item and I got the same result. Also, it appears you cannot run an inline function on a collection variable?? I have attached my WF, and help will be greatly appreciated!
I think you are almost there. Try ensuring your logic to count and update one item is good then ensure your logic is capturing a for each on every item.
Instead of querying the list and storing the created date, just do the calculation on each item that is queried:
By doing this your workflow will capture all items to be acted on. Then it will change each one via the for each according to the process inside the for each. To test this out, run the query then output the results first. Then run the same and add the for each and run the output results. You should see the same results letting you know that the for each will run against each item in the collection. So now you can apply your logic to the collection and it should run against each one. Another test would be to just update the items. Once that is done you can see which items are updated which again confirms that your logic is in the correct spot.
Let me know if that helps.Eric
Thanks for the information! One problem is (I think...) is that I am using a site workflow because the user wants these items updated on the entire list every 24 hours (because some items may site idle for days and the user wants the up to date running days an item has been in a particular status)... therefore I cannot insert a reference into my Build String action for the Created Date of the list..i need to query that list for the Created Date and store that date in a collection as well.... problem is I do not think you can use an inline function on a collection variable...I tried and my output was the following: fn-ABS(fn-DateDiffDays(5/2/16 7:29:50 AM; 5/2/16 7:30:04 AM; 5/2/16 10:29:41 AM;, 5/2/2016))... unless there is another way that I can insert the Created Date from the list into my site workflow without a query and store in a collection variable, not sure how else I can calculate the information I need...? Thanks!