Check Keyword in flow designer

preethigovi
Tera Contributor

Hi Team,

 

I need to check the short description that as keyword SAP  standalone in if condition of flow designer but we don't have script toggle. How we can achieve this.

 

I have script but not sure how to apply in if condition of flow

(function executeRule(current) {
var desc = current.short_description + ' '; // Ensure it's a string

// check for 'SAP' as a full word (case-insensitive)
if (/\bSAP\b/i.test(desc)) {
var groupName = gs.getProperty('incident.assignment.group');
current.assignment_group= groupName;
return true;
}

return false;
})(current);

 

preethigovi_0-1748870560764.png

 

2 ACCEPTED SOLUTIONS

OlaN
Giga Sage
Giga Sage

Hi,

That's correct, you cannot do a scripted condition in an IF-statement.

As a workaround, you can store the boolean option in a Flow variable (of type true/false), and evaluate it instead.

 

When setting the flow flow variable, you can enable scripting, and set the value to true or false, depending on the contents of your short description.

 

See attached example below.

Evaluate-Flow-variable.png

 

set-flow-variable-expanded.png

 

Script for reference.

var incidentShortDesc = fd_data.trigger.current.short_description.toString().toLowerCase();

if (incidentShortDesc.indexOf('sap') > -1){
    return true;
}
else{
    return false;
}

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@preethigovi 

you can use a flow variable and then use it in IF logic

Approach shared by @OlaN should work for you

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

View solution in original post

3 REPLIES 3

OlaN
Giga Sage
Giga Sage

Hi,

That's correct, you cannot do a scripted condition in an IF-statement.

As a workaround, you can store the boolean option in a Flow variable (of type true/false), and evaluate it instead.

 

When setting the flow flow variable, you can enable scripting, and set the value to true or false, depending on the contents of your short description.

 

See attached example below.

Evaluate-Flow-variable.png

 

set-flow-variable-expanded.png

 

Script for reference.

var incidentShortDesc = fd_data.trigger.current.short_description.toString().toLowerCase();

if (incidentShortDesc.indexOf('sap') > -1){
    return true;
}
else{
    return false;
}

Ankur Bawiskar
Tera Patron
Tera Patron

@preethigovi 

you can use a flow variable and then use it in IF logic

Approach shared by @OlaN should work for you

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

shreeux2
Giga Contributor

This step allows you to verify whether a specific keyword or phrase exists within a text variable, such as a user's message or a case description of N7. By using functions like CONTAINS() or FIND(), you can direct the flow down different paths based on the presence or absence of targeted words. This is particularly useful in customer support flows, chatbot responses, or categorizing cases based on user input. Properly implementing keyword checks enhances flow efficiency and ensures users receive contextually accurate responses.