how to set the "source" field in gs.info

david631
Giga Expert

How do I set the value of the "source" field in the "syslog" table from a server-side script?

The solution on How to use gs.log states that gs.info accepts "source" as its secondary parameter; however, I have tried this, and the "Source" field on the resulting message in the syslog table remains "*** Script". Furthermore, the official developer docs note that the parameters of gs.info act as variable substitution values for the first parameter:

Source: https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_ScopedGlideSystemInf_String_Object_O...

1 ACCEPTED SOLUTION

ARG645
Tera Guru

You cannot set the Source in gs.info. 

Why not use gs.log instead? 

gs.log("dummyMessage","dummySource");

View solution in original post

4 REPLIES 4

Yogi3
Kilo Guru

you can try using gs.info('message','source'). This will  add a log record in the sys_log table.

There is no "sys_log" table. name=sys_log returns null from the System Definition > Tables page. There is a "syslog" table, but the syntax you just described does not work. I explained that this syntax does not work in my original post, in fact.

ARG645
Tera Guru

You cannot set the Source in gs.info. 

Why not use gs.log instead? 

gs.log("dummyMessage","dummySource");

That works!

var logSource = "Notify case owner 2.0";
var instanceId = current.instance;
var emailType = current.type;
var targetTable = current.target_table;
var msg = logSource + ' current.type: ' + emailType + '\n' + 
	'target_table: ' + targetTable + '\n' + 
	'current.instance: ' + instanceId;

My problem was that I've been using the API Reference at developer.service-now.com, and this includes zero documentation for gs.log, so far as I can see. I see now that the JavaScript API reference on docs.service-now.com documents the function in question: https://docs.servicenow.com/bundle/madrid-application-development/page/app-store/dev_portal/API_refe....