Skip to main content

I have a list (List A), tracking items being destroyed. For each item being destroyed a unique tracking number needs to be generated after the requestor submits the request for approval.

field 1: Items being destroyed (drop down)

field 2: number of items being destroyed (number field)

So, if paper is being destroyed (field 1), the corresponding field number of boxes of papers (field 2) will also be filled.

Example, if the requestor is destroying 5 boxes of paper, I need to provide a unique tracking number for all five boxes. 

I am not using a repeating section as this form could easily have more than one repeating section based on what is being destroyed. My thought is to copy the list items (with some of the key fields) from List A to List B and generate a unique number from there.

In this case, I would need to create 5 list items in List B. I know how to copy the one item over, but not sure how to create the 4 additional reuqired list items over. Research shows I can use a counter variable, but considering there isn’t a collection and I am not using a repeating section, not sure how to incorporate a ‘for each’ action. Help and thank you.

Found the solution via another post - note, the items created on the second list do eventually show up - but with a slight delay

 

Original post URL

Best answer by bamaeric

You should be able to do this using the Loop action (and not the For Each action).

  1. Start by creating an Integer variable (named intItems) and set it to the value from the form of the number of items you want to create in the other list.
  2. Next add a Loop action and configure it as: Condition is "if any value equals value", Where "Workflow Data" intItems, 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" intItems
    • Minus
    • Value 1
    • Store result in = intItems
       
    This should loop through and create the desired number of items in the other list. For example, if the user enters 5 in the form, the workflow would loop to create 5 items in the other list.

My requirements have changed slightly. I now need to generate unique serial numbers based on a number field and update a multi-text field on that current list item. Example...number field shows 4, I need the WF to generate four unique serial numbers and update a multiline text field on that list. 


Hi isabellamai, 

Did the loop action worked for you to create x number of items? 

Because when I am trying to follow the same steps, the loop is running only once and the workflow stucks in-progress after that. 

If you or anyone has any idea on this, please contribute.  Thanks!


Reply