Loop with Condition not waiting for conditions


Badge +6

I have a Loop with Conditions that I can't seem to get to wait until each condition is true. Is my nexting of actions wrong? Each condition should wait until 3 SharePoint fields are not empty, but it just continues with the action and completes the whole workflow each time. Any ideas why it's not waiting for each condition to become True before continuing?

Thanks


12 replies

Userlevel 5
Badge +14

we would need to see your loop action condition and know in what condition it should run and in which it should stop

Badge +6

Hello again Marian- thank you! See attached. I assumed the loop would keep going around until each condition = True. But without ever putting anything into one of those 3 fields, the workflow just passes the loop and continues until the end.

It should keep looping until each of the 3 conditions=True THEN move on to send the next email.

loop with condition

Userlevel 5
Badge +14

I assumed the loop would keep going around until each condition = True.

that's correct.

while overall condition evaluates to true, loop is iterating over and over

the workflow just passes the loop and continues until the end...

what does this exactly mean?

does it goes over the loop body once, executes actions (sends notification) and then jumps out of loop?

or does it just reach loop action and then continue past the action (so skips loop body)?

But without ever putting anything into one of those 3 fields

you based your loop conditions on a set of list fields.  note users (usually) do not know something is running and looping in the background and so that they should change something asap.

this may cause long running or even infinite loops (and so wasting your farm resources). that's not proper design.

loop action is usually conditioned by a workflow variable which is changed appropriately within the loop to cause the loop to finish in a reasonable time or  after reasonable amount of iterations.

Badge +6

the workflow just passes the loop and continues until the end...

what does this exactly mean?

does it goes over the loop body once, executes actions (sends notification) and then jumps out of loop?

or does it just reach loop action and then continue past the action (so skips loop body)?  

Not sure if it goes around the loop but with NONE of the conditions every equalling TRUE, the workflow does Pause for Duration (I set it at a minute just for testing) but then after the minute it continues until the end.

I wanted the Loop to run once a day (Pause for 1 day) until each condition = true, THEN continue on to the next item (2nd email sent).   

The workflow runs until completed only pausing for "Pause for Duration" but the 3 conditions never = True and the workflow runs through until the end. Here's my workflow history that runs until completed without adding into to any fields in the List: 

Badge +6

OK I guess I was thinking of the Loop BACKWARDS.  Each condition should read IS EMPTY so the Loop starts, does that sound right to you? Then use another action to check that each field is NOT empty? 

Userlevel 5
Badge +14
Not sure if it goes around the loop

check the "View workflow history" (graphical overview). there you should see which actions were executed (green actions) and which not (grey actions)

the workflow does Pause for Duration (I set it at a minute just for testing) but then after the minute it continues until the end.

is the pause within the loop or out of the loop?

it's not present on your screenshot.

I wanted the Loop to run once a day (Pause for 1 day) until each condition = true, THEN continue on to the next item (2nd email sent).   

I think these are the main misunderstandings...

loop runs while overall condition is true, not until it is true. 

as well it evaluates the whole condition whether to proceed or not single expressions within the condition.

I wanted the Loop to run once a day

for this purpose it's better to design a site workflow, and schedule it to run daily.

THEN continue on to the next item (2nd email sent).   

I somehow miss the point of this design.

when workflow starts, it reads in bunch of items. then you want to send notifications one at a day.

so if you read in 100 items at the beginning you'll be ending them for 100 days....

if anything changes with those items in the meantime (eg, they may be deleted), your workflow will not reflect that.

OK I guess I was thinking of the Loop BACKWARDS.

hard to say for me what you were thinking of happy.png

Each condition should read IS EMPTY so the Loop starts, does that sound right to you? Then use another action to check that each field is NOT empty? 

I do not know. I do know what you want to achieve - in what circumstance loop should run and in which not.

but as I mentioned above, to condition looping on list field value is not wise design.

Userlevel 2
Badge +11

Indeed, the loop condition keeps looping while outcome is TRUE. Apart from changing the condition to Is Empty, you also should replace AND with OR, otherwise the condition stops as soon as 1 is no longer empty. Assuming that the loop should stop as soon as all 3 are no longer empty.

Badge +6

I understand now the loop condition keeps looping while the outcome is TRUE. I thought the complete opposite before. 

I want the workflow to send an email to a team and pause until that team fills in 3 fields that are required. I thought a Loop with Conditions was the action to do that. It would keep looping until each item was "not empty  then move on to the next item in the workflow. I guess now I don't really understand the point of the Loop if it runs while true.

I guess I need another action entirely. Workflow pauses until fields1, 2, and 3 are not empty. Once those are not empty, the next email is sent to the next team for the information they will supply. Workflow is paused until they fill in their fields, then it moves to the final step. 

Badge +6

Hello Jean-Pierre-- thanks for the information. Can you tell me if I use "or" for the 3 items, the loop will keep running until each of the fields has data in them, right? Once all 3 have data in them, the Loop condition is no longer true and it will move to the next step? 

Userlevel 2
Badge +11

Hi Mark,

Correct.

For determing/testing this you can use a table to determine the outcomes:

Is Fld 1 empty?Is Fld 2 empty?Is Fld 3 empty ?OR outcomeAND outcome
NoNoNoNoNo
NoNoYesYesNo
NoYesNoYesNo
NoYesYesYesNo
YesNoNoYesNo
YesNoYesYesNo
YesYesNoYesNo
YesYesYesYesYes

If I recall correctly there's some math available assisting you with this kind of logic.

Userlevel 5
Badge +14

I want the workflow to send an email to a team and pause until that team fills in 3 fields that are required.

that's typically managed with tasks.

assign a task to the team or single team members. task action causes workflow to pause until task is responded.

tasks as well gives you broader possibilities how to manage what's being considered as task completed or not (single response from any team members is sufficient, all must respond...), manage what's being done if task is not responded within reasonable time frame,  automatically delegate the to some else if originally supposed team or team member is not able to respond (eg. he is out of office), etc.

have a look on flexi task, to do task, request review, request data, ... actions

It would keep looping until each item was "not empty  then move on to the next item in the workflow

do not try to manage processing of all/several list items from within single workflow instance (until you have good reasons to do so).

design the workflow to take care just of processing of single item, and let the separate (list) workflow instances run on each list item independently. that way all the items will be processed in parallel, so processing of list item #2 will not wait until item #1 is processed, item #3 will not wait on item#2, and so on.

I guess now I don't really understand the point of the Loop if it runs while true.

loop action is very useful. imagine eg. you want to create a 10 items. so you configure a loop action and let iterate while some control variable is less then 10

I guess I need another action entirely.

as mentioned above, I guess a task action would suit you the most

Workflow pauses until fields1, 2, and 3 are not empty. Once those are not empty, the next email is sent to the next team for the information they will supply. Workflow is paused until they fill in their fields, then it moves to the final step. 

that's exactly how tasks works. until task is responded, the workflow doesn't move on.

furthermore, filling some fields in a list item is independent of a task response. so user may step by step prepare data and update list item fields even multiple times (if that might be needed) until they finalize it, workflow doesn't move on until they explicitly respond the task.

Badge +6

Thanks so much, Marian- I appreciate it. I was trying to avoid using tasks because the tasks would have to go to a distribution group and it seems like  it would create a lot of confusion as to who was working on which item. It's certainly something to keep in mind, though. There's not much to this particular workflow that can run in parallel because some information is not possible to have until prior info is given. I think it is short enough that this work ok now. I sure appreciate all of your assistance. It's really working great now that I have Loops correctly in my head happy.png    

Reply