Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get only script value using gs.print

kavyahv
Kilo Contributor

Dear All,

Please help how can get only script value result in background script.

When i run the background script i all get time and other information with the script result

Also is there any possibility only to export the script result to csv.

Thanks in advance,

Kavya

2 REPLIES 2

leochavez
Tera Guru

Hi Kavya,



Use gs.log() in place of gs.print() to have output write to the log table.   The following example will query the sys_user table for 10 records, iterate and write them to the log table.



var logSource = "User Script";


var sysUserGR = new GlideRecord('sys_user');


sysUserGR.setLimit(10);


sysUserGR.query();



while(sysUserGR.next()) {


  gs.log("User : " + sysUserGR.name, logSource);


}



You can then filter the log table source column for 'User Script' and export the results in the appropriate format.   I hope that's what your after.



- Leo


sachin_namjoshi
Kilo Patron
Kilo Patron

Below post has solution to your question



Script Background - GS.PRINT - value from databse



Regards,


Sachin