Skip to main content

So I have a site workflow that runs daily that is supposed to look at a list and find ones where the "Next Review Date" == Today. For items where this is true, it's supposed to set the columns "Status" and "WFStatus" to "Expired" and then begin a list workflow for these items. The list workflow then checks to see if "Status" == Expired and if "Next Review Date" == Today and then complete some actions if so.

 

The issue I'm having is if there is more than one list item where "Next Review Date" == Today. For the first one, it does everything correctly. For the second one, it doesn't update the field values, but it does start the workflow. But since the conditions in the List Workflow aren't met, the list workflow exits.

 

Here is how the Query List Action is configured:

queryList.png

I tried having it give a separate output per column as well, which didn't give any different results.

 

Here is what's after the Query:

afterQuery.png

 

And here's how the For Each is set up:

forEachLoop.png

I can see in the Site Workflow logs that it is seeing two items that meet the criteria and then when I go to each item in the list I can see that the list workflow was started, but on one of them, the fields haven't been updated.

Hi Courtney,

If you manually run the List Workflow on the item that was not updated, are the fields modified?

Regards,

Christophe


Hi,

could you post how the update item si configured? I think that there could be an issue there so it doesn't complete correctly that action..

Giacomo


The list workflow doesn't modify/update fields, it has a runIf fields == things and the Site workflow is supposed to set the fields to things. It does it for the first item, but not any further. For example, if there are three items with a Next Review Date of today, it will update the fields for the first item, but not the other two. But, it will start the list workflow on all three. Since the setting of the fields didn't happen for items two and three, the runIf condition is not met for those two.

Edit to Add: I know that the loop sees all three or two or however many items because I have a variable for the count that logs that is always correct


I don't think the "Update Item" is the problem because it completes the item update correctly for the first iteration of the loop, but here it is:

updateListItem.png


Hi Courtney,

the issue is right there..Update Item action does an update only to one item, so looking at the configuration it search for an item where NextReviewDate = Today and it returns always the first one.

You can solve this issue if in the query list you retrieve also the ID of the item and then you get it inside the For Each, in order to update the id-related item in each loop of the for each.

Otherwise you can sobstitute the Update Item with the Office 365 Update Items action (to be put before the For Each) that allows you to update multiple items based on your condition.

Hope this help

Giacomo


Shouldn't the "For Each" loop iterate per item though? If this is the case, then the "update Item" should happen per iteration and thus per item.


Yes, the For Each iterate per item returned by the query, in fact it execute the update item and the start workflow for each item.

The problem is that, the condition you have set in the update item, isn't tied to any variable that is connected to the iteration but it's generic, so it will always return the same item to update.


This seems odd and backwards....can you expand on how you would reconfigure the "For Each"?


Hi Courtney,

I will do the following changes:

Query List Output:

QueryList.PNG

(in this way you have a collection of all the item IDs who respect your filter)

For Each:

ForEach.PNG

(you take your collection and in each iteration you save the single ID value in a variable)

Update Item:

UpdateItem.PNG

(in the Update Item you updating only the item with the specific ID you get from the query list and the iteration)

I think previously you were getting also the GUID in order to use it in Start Workflow Action, but I've seen that you can also use ID in order to specify on which item you want to start the list workflow, so you don't need anymore the GUID.

Giacomo


Does the Update Item go before or inside of the For Each Loop?


Hi,

the Update Item goes inside the For Each loop (it uses a variable defined in the output of the For Each action).

Giacomo


Reply