The CreatorCon Call for Content is officially open! Get started here.

I've a requirement to trigger the task when a variable - 'ABCD' is '1','2','3','4'

Trupti Krishnam
Tera Contributor

I've a requirement to trigger the task when a variable  'ABCD' is '1','2','3','4' .Where ABCD variable is a 'LookUp Select Box' and Its declared with in the MRVS Variable set 

Please help me how to write a script to access this variable in the workflow If condition .That would help me trigger the task.

 

Thanks!

4 REPLIES 4

HIROSHI SATOH
Mega Sage

Sample Script:
You can use a Script in the Flow Designer’s If condition as follows:

// Assuming 'current' is the GlideRecord of the task or record you are working with
var mrvs = current.variables.multi_row_variable_set_name; // Replace with your MRVS name
var triggerTask = false;

mrvs.forEach(function(row) {
    var abcdValue = row.variables.ABCD;
    if (abcdValue == '1' || abcdValue == '2' || abcdValue == '3' || abcdValue == '4') {
        triggerTask = true;
    }
});

triggerTask; // This will return true if any row has the desired value, triggering the task

Trupti Krishnam
Tera Contributor

I 've tried this but it's not working in the if condition

 

Added consideration and break for NULL.

 

var mrvs = current.variables.multi_row_variable_set_name;
var triggerTask = false;

mrvs.forEach(function(row) {
    var abcdValue = row.variables.ABCD;
    if (abcdValue !== null && typeof abcdValue === 'string' && 
        (abcdValue === '1' || abcdValue === '2' || abcdValue === '3' || abcdValue === '4')) {
        triggerTask = true;
        break; // Break the loop if a condition is met
    }
});

 

Trupti Krishnam
Tera Contributor

did not work