debug, gs.log doesn't work in business rule

jean-lucchatton
Kilo Guru

Hi,

I'm facing a weird issue in a business rule : the gs.log() doesn't write anything in the syslog.

We have defined an application menu "Assigned" to get the incident assigned to the groups that a person belongs to. In the menu, we set a filter condition "assignment group is javascript:GetMyGroups"

find_real_file.png

The function "getMyGroups" is OOB and defined in the business rule "groups, banners". As we wish to return only specific groups (i.e. the groups for assignment not the technical ones), I wish to change the code (I will make a copy).

So I've began with a gs.log, but it doesn't write anythink in the syslog

function getMyGroups() {

  gs.log("IN GET MY GROUPS OOB");

  return gs.getUser().getMyGroups();

}

Very strange....

Could you help me ?

Thanks

Jean-Luc

1 ACCEPTED SOLUTION

Thanks Jean-Luc. Didn't you say that this is a scoped app? If so, gs.log is off limits. Change it to gs.info and see if your script produces output. For best visibility to what's going on, turn on business rule debugging.



System Diagnostics> Debug Business Rule (details) and observe the output at the bottom of your form or list after   you save your changes.


View solution in original post

12 REPLIES 12

Geoffrey2
ServiceNow Employee
ServiceNow Employee

gs.log doesn't work in Scoped Applications.   You need to use gs.info() or gs.debug() etc instead.


So is your Business Rule in a Scoped App?


Hi Geoffrey,


This is a scoped application


Geoffrey2
ServiceNow Employee
ServiceNow Employee

Actually, I think what you're trying to do is call a global Business Rule.   What you need to do instead is create a Script Include.


Screen Shot 2016-09-29 at 6.06.04 PM.png


Then use javascript: new GroupUtils().getMyGroups()


Hi Geoffrey,



Thanks for your 2 answers.



I've tried what you have written but it doesn't work either.



The original business rule and your script include are called both. That works. But the problem is that no the gs.log has zero effect.