Flow Designer: For Each action with Multi Row Variable Set and Select Box

sharvil Sheth1
Kilo Guru

I have one multi row variable set and it has one variable "Acquisition Method" type is select box with options "Lease" and "Purchase". and user will be edit this variable in catalog task level, not while submitting request, it's hidden while submitting the request.

If "Purchase" is selected then there are few steps, same if "lease" is selected there are other steps.

If I select multi records then also it reflects with first record.

 

sharvilSheth1_4-1743095013275.png

 

 

 

sharvilSheth1_2-1743094768452.png

sharvilSheth1_3-1743094913026.png

 

1 ACCEPTED SOLUTION

I have achieved this with Flow Action "Look Up Record".

View solution in original post

10 REPLIES 10

@sharvil Sheth1 

so what's your question?

what's not working?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

sharvilSheth1_0-1743136994509.png

it is checking only 1st record and not the 2nd, it should check both, rather it should iterate through all the records.

 

@sharvil Sheth1 

then use 2 flow variables to check the count of Purchase and Lease and then use Set Flow Variable logic

In the inline script you can parse the JSON from MRVS and then increment the count and then set the flow variables.

Then use IF logic to check the count of each and have your logic

Something like this

I hope I have provided enough information and you can enhance it from here

flow variable count mrvs.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I tried,

var count = 0;
var mrvs = fd_data._1__get_catalog_variables.add_hardware_models_for_this_request.toString();
var parsedData = JSON.parse(mrvs);
for(var i=0;i<parsedData.length;i++){
if (parsedData[i].acquisition_method == 'purchase') 
    count = count + 1;
}
return count;

but facing with below error 
ncountered error executing instruction: OpInstruction{id=42, opClass=com.snc.process_flow.operation.script.InlineScriptOperation, io=Io{input={required_run_time=RefOrValue{value=vanilla, isRef=false}, _1__get_catalog_variables_add_hardware_models_for_this_request=RefOrValue{value=c1o.add_hardware_models_for_this_request, isRef=true}, script=RefOrValue{value=(function (inputs, outputs) {outputs.__...

sharvilSheth1_0-1743141645664.png

 






@sharvil Sheth1 

did you add logs and see?

try this

var count = 0;
var mrvs = fd_data._1__get_catalog_variables.add_hardware_models_for_this_request.toString();

gs.info('json is' + mrvs);

var parsedData = JSON.parse(mrvs);
for(var i=0;i<parsedData.length;i++){
if (parsedData[i].acquisition_method.toString() == 'purchase') 
    count = count + 1;
}
return count;

Did you include that MRVS variable set in the Right side of bucket in "Get Catalog Variables"

are you using correct mrvs variable set name?

are you using correct variable name present within MRVS?

are you using correct value to compare?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader