1

Put another way.

Using a loop, how do I pass the number of items in a list to an action outside the loop?

I have created a loop and within the loop I have added an action to calculate a data value as follows

Data selector: 'loop_name:quantity' 

Calculation: *1 = calculation_result

From within the loop I can access the new variable 'calculation_result' however I can not figure out how to expose the calculation result to other data selectors.

What steps am I missing?

2

You have to create a new variable BEFORE your loop.

Select add a variable from rules action

And then select the type of variables in that list. For your example, perhaps a list of decimals?

Select a list of decimals

Be sure to give it a good custom name for your loop:

Give the variable a good custom name

Then, in your loop, you can add a new variable to an existing list:

Add an item to a list

Then, after your loop, you can access calculation results:

Select from a list

Note, that if you don't know explicitly which in your loop you want, then you will have to loop through your new calculation results and use a condition rule to return the one you need as (yet another) variable.

  • Thank you for this most comprehensive answer. It must have taken you ages – MrPaulDriver Dec 17 '15 at 23:22
  • @MrPaulDriver yet you never accepted his answer by clicking the checkmark, nor voted him up so he gets reputation points (-_-) – No Sssweat Jan 9 '16 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.