- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:31 AM
Hi All,
Can someone please advice, How can we check if Array if it is null or undefined in Transform map OnAfter Script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:35 AM
Hi,
you can check if array is empty
var arr = ['a','b'];
if(arr.length ==0){
// empty
}
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
08-30-2022 02:05 AM
Hi
What did you try in encodedquery?
One option is to use:
if(arr.indexOf('invalid') > -1){
//goes inside if, when invalid is present in the array arr
}else{
//when invalid is not present in the array arr
}
Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.
Will be helpful for others looking for the similar query.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:36 AM
Hi Ankita,
You can use the available OOB script includes JSUtil
JSUtil.isEmpty()