HOW TO PRINT THE RESULT OF A BUSINESS RULE ON THE CONSOLE?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 03:11 AM
for example i want to print all the active records
i created a business rule by following conditions
when to run:
BEFORE INSERT/UPDATE
SCRIPT:
var x=new GlideRecord('incident');
x.addActiveQuery();
x.query();
while(x.next())
{
gs.print('active record number'+x.number);
}
but i am not getting any out put on the console
i want to test all the GlideRecord methods with output how it is possible??
- Labels:
-
Enterprise Asset Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 03:15 AM
Hi Shabbir,
you have to use gs.log("Your Message"); inside business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 03:15 AM
Hi Shabbir,
You can try below methods to print your results for testing purposes on SNOw screen,
1. gs.addInfoMessge("your message" +x.number); --> Will be displayed as info in blue color
2. gs.addErrorMessage("your error message" +x.number) ; --> Will be displayed as error in red color
You can find more glide system elements in this link GlideSystem - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 03:26 AM
i tried it but i am not getting the output
this is my code::
var x=new GlideRecord('incident');
x.addActiveQuery();
x.query();
while(x.next())
{
gs.addInfoMessge("the active incident number is " +x.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 03:40 AM
Maybe a silly question but do you have active Incidents in your Incident table? Also, what conditions are triggering this rule? Is it definitely firing? Also, you've spelled addInfoMessage wrong.
try changing the loop to and if and say:
if (x.hasNext()){
gs.log('There is an active Incident');
}
hasNext() returns true or false depending on your conditions, if this doesn't return an response then you have no active incidents.