How do I iterate through a multi row variable set in Flow Designer?

Jacob Saaby Nie
Tera Contributor

Hi everyone.

So I have a catalog item. In that, I'm using some multi row variable sets. That all works just fine.

However, in my flow I would like to be able to get a list of what people actually ordered. Those things are in that multi row variable set.

What I want to do is get the elements in the mrvs, so I can write out the variable choice names in an email, and then send that.

Can any of you help me figure out how to do that? I'm pretty proficient in Flow Designer, just not code 😉 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Jacob,

Flow Designer supports mrvs. To get each row, use "For Each Item in"

Example:

find_real_file.png

find_real_file.png

find_real_file.png

View solution in original post

10 REPLIES 10

Allen Andreas
Administrator
Administrator

Hi,

In Flow Designer, you'd use the same concept of retrieving those catalog variables as normal.

Then, for the MVRS, you'll see that it's an ArrayObject. From there, within the flow, you'd add a For Each Item step to walk through that ArrayObject, you could assign this to flow variables if needed.

Or, if you're sending a notification from the flow, you should be able to use the ArrayObject and write a script yourself to iterate through it, here's an example of a script action you could also use:

var sysID = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(sysID);
var arr = [];
var mrvsVar = rec.variables.name_of_mvrs_variable;
var parser = JSON.parse(mrvsVar);
for(var i=0;i<parser.length;i++){
	arr.push(parser[i].variable_name_within_mvrs.toString());
}

So a few different options here. I'd recommend trying a bit and then let us know if you get stuck and if so, where at, so we can help further.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I'm glad your question was answered.

I believe I covered all of that above and gave additional information as well, but perhaps you enjoyed the screenshots.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen.

And I appreciate your answer. However, the answer most useful to me (at least initially) is the one that primarily keeps me in Flow Designer with as little scripting as possible.

I usually go for more FD, less scripting, in my solutions 🙂

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Jacob,

Flow Designer supports mrvs. To get each row, use "For Each Item in"

Example:

find_real_file.png

find_real_file.png

find_real_file.png