Create a workflow If statement to look for sub string in a string

Peter Williams
Kilo Sage

Hi everyone,

 

how can i program this better, i want to be able to convert the string into lowerCase and then search for the lowercase sub sting in the If Statement

 

PeterWilliams_0-1709144620173.png

 

1 ACCEPTED SOLUTION

 

 

If condition updated.

make sure the variable afa returning string type value [ not an object type ]

in case, afa is returning Object, then add .toString().toLowerCase();

 

 

answer = ifScript();
//
var proBono = current.variables.afa.toLowerCase();
function ifScript() {
if (proBono.indexOf('pro bono') > -1 ) {
return 'yes';
}
return 'no';
}

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

7 REPLIES 7

AshishKM
Kilo Patron
Kilo Patron

Hi @Peter Williams,

You can try with "Advance" section script and use the toLowerCase() method.

var afaValue = current.variables.<afa_variable_name>.toLowerCase(); //replace the correct afa_variable_name

or

var afaValue = current.variables.<afa_variable_name>.toString().toLowerCase(); //replace the correct afa_variable_name

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

so would this work then cause i need to check a sub string in a string

 

answer = ifScript();
//
var proBono = current.variables.afa.toLowerCase();
function ifScript() {
if (proBono.indexOf('pro bono')) {
return 'yes';
}
return 'no';
}

Ideally this should work.

 

answer = ifScript();
//
var proBono = current.variables.afa.toLowerCase();
function ifScript() {
if (proBono.indexOf('pro bono')>-1) {
return 'yes';
}
return 'no';
}

 

 

If condition updated.

make sure the variable afa returning string type value [ not an object type ]

in case, afa is returning Object, then add .toString().toLowerCase();

 

 

answer = ifScript();
//
var proBono = current.variables.afa.toLowerCase();
function ifScript() {
if (proBono.indexOf('pro bono') > -1 ) {
return 'yes';
}
return 'no';
}

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution