How to check iF condition in workflow for MRVS

Piyush291
Tera Contributor

HI,

i have created a catalog item and user MRVS in that, there are 2 fields in multi row

request_type = action and deletion

association = Non government and government

Now i want a condition to check if request type is action or deletion && association is No government then its Yes otherwise No

I tried to write MRVS script but not working

Multi row variable set internal name: declaration_list

1 ACCEPTED SOLUTION

@Piyush291 

you didn't answer my above question

are you saying if any 1 row satisfies that condition then you want to return yes or all rows should satisfy that condition?

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

View solution in original post

13 REPLIES 13

Piyush291
Tera Contributor

@Ankur Bawiskar 

Can you please help in the script

@Piyush291 

you need to parse and check the json value

are you saying if any 1 row satisfies that condition then you want to return yes or all rows should satisfy that condition?

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

Below script is the normal if condition and i want same but variables are in MRVS

answer = ifScript();

function ifScript() {
if (current.variables.declaration_type == 'Gift' || current.variables.declaration_type == 'Hospitality' && current.variables.associate == 'Non Government Official') {
return 'yes';
} else {
return 'no';
}
}

@Ankur Bawiskar 

I have written the if script in workflow with below code, But it is always taking to No condition, Also when i tested with background with script it is coming Yes but dont no why No in workflow

function ifScript() {

    var multiRowVarSet = current.variables.declaration; // variable set internal name

    var rowCount = multiRowVarSet.getRowCount();

 

    for (var i = 0; i < rowCount; i++) {

        var row = multiRowVarSet.getRow(i);

 

        var declarationType = row.declaration_type;

        var associate = row.associate;

 

        if (declarationType == 'Gift' || (declarationType == 'Hospitality' && associate == 'Non Government ')) {

            return 'yes';

        }

        return 'no';

    }

}

@Piyush291 

you didn't answer my above question

are you saying if any 1 row satisfies that condition then you want to return yes or all rows should satisfy that condition?

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