
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 11:15 PM
Hi All,
I'm facing strange issue in our platform that both indexOf() and includes() is giving unexpected output.Also I verified this works fine for single value,only issues are occuring when values are seperated by comma or like multiple values. Suspecting to break many codes. Need help.
Below script is giving '-1'/'false' as output.
var abc= '6a225461db861c50d4002db614961967';
gs.info(abc.includes(gs.getProperty('property_name')));
System Property:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 11:27 PM
Hi,
you can use OOB ArrayUtil class to check using contains function instead of indexOf
var abc= '6a225461db861c50d4002db614961967';
var arr = gs.getProperty('property_name').toString().split(',');
var arrayUtil = new global.ArrayUtil();
var isPresent = arrayUtil.contains(arr,abc);
gs.info(isPresent);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 11:29 PM
We can easily overlook certain things, right!
Happened with me several times 😉
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2022 03:38 AM
Thanks Aman for the RCA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 11:27 PM
Hi,
you can use OOB ArrayUtil class to check using contains function instead of indexOf
var abc= '6a225461db861c50d4002db614961967';
var arr = gs.getProperty('property_name').toString().split(',');
var arrayUtil = new global.ArrayUtil();
var isPresent = arrayUtil.contains(arr,abc);
gs.info(isPresent);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader