Able to fetch required result in background script but the same logic is unable to give expected results when ran on Business rules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 05:43 AM
Able to fetch required result in background script but the same logic is unable to give expected results when ran on Business rules.
This the logic we tried in background script,working as expected it printed 6 times:
The same logic when tried on Business rule doesn't even print once:
Any help is appreciated!
Thanks.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 05:52 AM
Hi Aindrila,
Working with sys_ids can be tricky. The issue is around sys_ids not being strings. The general rule of thumb is to use code like this:
var num3 = current.sys_id.toString();
I suspect that adding a toString() to getUniqueValue() will give you the same result.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 05:59 AM
Hi,
Thanks for your reply.I tried as you mentioned but still it didn't workout.
var num3=current.getUniqueValue().toString();//sys_id of result record in scan_result
var s=new GlideRecord('scan_suite_execution');
s.addEncodedQuery('result='+num3);
s.query();
while(s.next()){
gs.log('record is matching');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 06:06 AM
Hi Aindrila,
Have you run your BR through the debugger? That will let you see what value is going into num3. Also for debugging purposes you can add:
var sQuery = s.getEncodedQuery();
Did you try
var num3=current.sys_id.toString()
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 05:52 AM
Hi,
Try current.sys_id instead of current.getUniqueValue()
If still didnt work, then put a log for num3 and see what value is printed..
Regards,
Sumanth