How to convert "contains" as operator

Jeni Sebastian
Mega Contributor

Hi everyone! 

I have an existing business rule and I need to insert a condition inside the script using  "if (current." 

Condition :  If "user account" field contains "ETC"  

Field: u_useraccount

Field Type: string

What I did was this and I know that it's not really correct since I used "==".

if(current.u_useraccount =="ETC"){

}

 

I'll appreciate if someone respond to this. Thanks in Advance! 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

You can use:

var str = current.getValue("u_useraccount");

if(str.indexOf("ETC") > -1){// checks if u_useraccount contains ETC, indexOf returns -1 if not found, else returns the index where the substring is found.

Best Regards
Aman Kumar

View solution in original post

5 REPLIES 5

Hi Aman,

 

Does it work for List type field as well ?