- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 07:14 AM
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!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 07:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 07:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 07:49 AM
Hi
So if the condition is : "DOES NOT CONTAIN"
will it look like this?
if(str.indexOf("ETC") < -1){
sorry is that right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 07:50 AM
It should be like below,
if(str.indexOf("ETC")== -1){
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 07:53 AM
It should be:
if(str.indexOf("ETC") == -1){
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂