low code Flow - set flow variables from for each loop look up

Taza
Tera Contributor

Hi there,

 

I have a low code flow where I have used @Ankur Bawiskar List Collector Convert to Array action which works fine however I am struggling to set flow variables based on the output of the for each loop (based on the value from the List Collector Convert to Array action. 

The flow variables will only ever set for the first value obtained as part of the loop and so it's pretty useless for now. How do I set a flow variable for each item looked up in my loop?

 

Taza_0-1729076339175.png

 

Taza_3-1729076558244.png

 

 

 

Taza_2-1729076496894.png

 

 

output from the loop:

Taza_1-1729076405292.png

 

please let me know if you require any more information

 

Thanks

3 REPLIES 3

JenniferRah
Mega Sage

To set a variable in a MRVS (Multi-Row Variable Set) within a Flow, the only way I have been able to do that is to write a custom Action and script the change that needs to be made. It's unfortunately very customized to the particular MRVS and variable(s) you need to change.

Taza
Tera Contributor

Hi @JenniferRah  

 

Thanks for your response, are you able to share your action and script with me? 

 

Thanks

JenniferRah
Mega Sage

I don't know how much help it will be. It is very specialized for my specific MRVS and form, but I will paste a version of the code below.

 

For the Inputs, I have a RITM variable that is a Reference to sc_req_item. It just has one Script action, which is below. I tried to make the code as generic as possible, but this goes through each item in the MRVS and resets a Yes/No variable to blank if the value is No.

 

(function execute(inputs, outputs) {
    var gr = new GlideRecord('sc_req_item');
    gr.get(inputs.ritm.sys_id);
    var mrvs = gr.variables.mrvsname;
    var rowCount = mrvs.getRowCount();
    for (var i = 0; i < rowCount; i++) {
        var row = mrvs.getRow(i);
        if(row.vartochange == 'No'){
            row.vartochange = '';
        }
    }
    gr.update();
})(inputs, outputs);