- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 12:18 AM
Hi Team,
I declared 30 plus sys id in property as comma separated and wanted to call that in scheduled job.
I need to query HR task table and the pass this sys id in template reference field in HR task and perform some updation.
Its printing the sys ids in log prev11 but not entering the while loop. I guess there is some error in encoded query while i try to pass the list of sys id from property
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 12:29 AM
Hi @preethigovi
Please try the below script.
var offboardingTaskSysId = gs.getProperty('sn_hr_core.offboarding task sys id').toString();
var getAllTask = new GlideRecord('sn_hr_core_task');
gs.info("preeV11" +offboardingTaskSysId)
getAllTask.addEncodedQuery('templateIN'+ offboardingTaskSysId);
gs.info("Preein")
getAllTask.query();
while (getAllTask.next()) {
gs.info('PreeD1');
}
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 12:40 AM
I assume your system property holds comma separated sysIds and is of type string
update your code as this
Since you are comparing multiple sysIds, you need to use IN operator and not =
getAllTask.addEncodedQuery('templateIN'+ offboardingTaskSysId);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 02:26 AM
@Robert H Thank you for suggestion Robert, i will check this with business team and make something common check to achieve. Thanks again