Skip to main content

I wish to automatically create x number of items in a SP Custom list. For this I am using below steps, but the loop runs only 1 time and remains in in-progress state after that. 

  1. Start by creating an Integer variable (named x) and set it to the value from the form of the number of items you want to create in the list.
  2. Next add a Loop action and configure it as: Condition is "if any value equals value", Where "Workflow Data" x, is greater than, Value 0.
  3. Inside the Loop action, add and configure the create item action (i.e. "Create item" or "Create item in another site" action). 
  4. Then inside the Loop action and after the previous step, add a Math Operation action and configure it as: 
    • Calculation "Workflow Data" x
    • Minus
    • Value 1
    • Store result in = x

Only 1 single item gets created and nothing really happens after that. Any idea why this is happening? 

Note: This is for SharePoint 2019 on-Prem version of Nintex.

My guess is it’s the loop delay. The loop function has a built-in delay of about 5 minutes per cycle, this is to prevent accidental infinite loops from overloading the server. Depending on the situation you can sometimes lay it out differently so you don’t need as many cycles or run different cycles simultaneously through parallel actions. The For Each action can also be used to loop and doesn’t have a delay, but it needs a (dummy) collection variable input that needs at least as many entries as the number of cycles you want the loop to go through which can be a bit cumbersome.


Ok, not very helpful to use Loop then. But I saw that even after couple of hours, there were no more items created. Am I missing any other settings or its some kind of bug? 


It’s difficult to say from this side. Workflow history can sometimes reveal where a workflow currently is in progress (like what it has done and what is still pending) or give specific errors. The loop delay should just show the loop as still in progress (yellow coloured action in the history overview), and with an inactive time since the last cycle, but it really shouldn’t take hours to start the next cycle. What does the workflow history show with regards to the loop? Is it in progress and pending, is it complete (green colour), is there an error (you can find in the detailed workflow history)?


Hi @Nayan20 

 

As @BobR has stated, its difficult to pinpoint the root cause of the issue(s).
You need to DEBUG your workflow. Use as many or Log to History action as you need during the debugging process.

1 Log action before entering LOOP

1 Log action at the start of the LOOP

X Log action inside the LOOP. Show LOOP variables 

1 Log action at the end of the LOOP

1 Log action after exiting LOOP

 

Test with the following workflow scenario

  • Count is 0. No Looping (does not enter Loop)
    Outcome. Log for Before Enter and After Exit
  • Count is 1. Perform loop action once and exit
  • Count is 2. 
  • Count is 3 or more 

 Hopefully this can help to troubleshoot the issues


Perhaps adding a Commit Pending Actions action after the item creation and the calculation...


Reply