- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 04:18 AM
Hi everyone!
I would like to ask how to write a script for the condition :
If account field contains "OOO" and if account field does not contain "NA"
Here's what I did :
var str = current.getValue("u_account");
if((str.contains("OOO")) && (str.doesnotcontain("NA"))){
But it seems like it doesnt work for the "&& (str.doesnotcontain("NA"))"
Thank you in advance!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 04:25 AM
Here is another option:
var string = current.getValue("u_account");
if((string.contains('OOO'))&&(!string.contains('NA'))){
gs.info('the string contains OOO and does not contain NA')
}
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 04:22 AM
var string = current.getValue("u_account");
if((string.indexOf('OOO')!= -1)&&(string.indexOf('NA')==-1)){
gs.info('the string contains OOO and does not contain NA'); // replace with your code
}
Please mark Correct and Helpful if my answer helps you resolve your issue. Thanks!
Martin Ivanov
Community Rising Star 2022
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 04:25 AM
Here is another option:
var string = current.getValue("u_account");
if((string.contains('OOO'))&&(!string.contains('NA'))){
gs.info('the string contains OOO and does not contain NA')
}
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2024 01:23 AM
Thank you it worked!