- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 11:40 AM
The below code does not print to the script log statements from the security incident scope. I am having issues with the conditions on the business rule however after removing all conditions and validating that the code itself works upon form update of a record I still do not see these gs.info() logs in the script logs table. I've only ever used gs.log() before having done all development in the global scope so I'm not sure if there's something I'm missing here. Any help would be appreciated.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.info('Current.severity before setting: '+current.severity);
gs.info('Previous.severity before setting:'+previous.severity);
current.severity = previous.severity;
gs.info('Current.severity after setting: '+current.severity);
gs.info('Previous.severity after setting:'+previous.severity);
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Scoped App Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 12:00 PM
HI,
They might be printing but then you are trying to see them using script log which may filter you logs. When you open the logs table just make sure the source field is empty.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 11:48 AM
The format used is correct may be you can try using gs.addInfoMessage() or gs.ErrorMessage() since its business rule.
Even if it dosen't get printed then I doubt you business rule is executing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 11:50 AM
Hii,
gs.log is restricted to global scope. However ServiceNow Elite did a nice blog of alternative logging methods
https://www.servicenowelite.com/blog/2018/9/18/logging-for-scoped-applications

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2020 12:00 PM
HI,
They might be printing but then you are trying to see them using script log which may filter you logs. When you open the logs table just make sure the source field is empty.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2020 06:51 PM
Thanks, after changing it to gs.error and getting rid of the source field filter on the log table I can see it.