The CreatorCon Call for Content is officially open! Get started here.

Scripts - Background goes blank on execution

georgechen
Kilo Guru

Hi folks

Anyone has idea about Scripts - Background result screen providing inaccurate information when a record update script under Scripts - Background.     Just to exemplify the issue, when a record updates script is executed, it writes

"*** Script: Records to be updated:0

*** Script: Records to be updated:0

*** Script: Date Updated,Number,State,Caveat,Assignment Group,Date Created

*** Script: Date Updated,Number,State,Caveat,Assignment Group,Date Created"

The execution results however can be retrieved in Script Log Statements under System Log      

30-10-2015 17:24:05InformationRecords to be updated:1350*** Script
30-10-2015 17:24:05Information30-10-2015 17:24:05,HR0055345,Check and File,HR Support,HR Managed Records Team,2015-05-13 00:11:34*** Script
30-10-2015 17:24:05Information30-10-2015 17:24:05,HR0219116,Check and File,HR Support,HR Managed Records Team,2015-08-13 00:04:35*** Script
30-10-2015 17:24:05Information30-10-2015 17:24:05,HR0070881,Check and File,HR Support,HR Managed Records Team,2015-05-21 00:49:35*** Script

Please find the script below,

The target records were fortunately updated properly

var grHR = new GlideRecord('hr');

grHR.addEncodedQuery("active=true^state!=7^u_caveatISEMPTY^assignment_group=f7a3cdfa60b4f100d0b93a90c5b62e74");

grHR.query();

//Output the Total Number of Records retrieved by the query

gs.log('Records to be updated:' + grHR.getRowCount());

gs.print('Records to be updated:' + grHR.getRowCount());

// Print the column headers for the output list

gs.log('Date Updated,Number,State,Caveat,Assignment Group,Date Created');

gs.print('Date Updated,Number,State,Caveat,Assignment Group,Date Created');

while (grHR.next()) {

grHR.u_caveat = '8e34000b68d26100454fd59ef9c80f8b'; // HR Support

grHR.update();

var datToday = new GlideDateTime();

gs.log(datToday.getDisplayValue() + ',' + grHR.number + ',' + grHR.state.getDisplayValue() + ',' + grHR.u_caveat.getDisplayValue() + ',' + grHR.assignment_group.getDisplayValue() + ',' + grHR.sys_created_on);

gs.print(datToday.getDisplayValue() + ',' + grHR.number + ',' + grHR.state.getDisplayValue() + ',' + grHR.u_caveat.getDisplayValue() + ',' + grHR.assignment_group.getDisplayValue() + ',' + grHR.sys_created_on);

}

So here is the questions

1) why the discrepancy occurs between the run time output screen and the system logs with exactly the same script.

2) If memory serves me right, gs.log writes to system log whereas gs.print writes to console window (output window).   It seems gs.log also tries to output to console as well?

Any advise would be given credits.

Kind regards,

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

Hi georgechen,



I hope you're doing great!



Were you able to give it a try by running your script again? Do you have any other further questions on this?



Thanks,


Berny


View solution in original post

5 REPLIES 5

Great!! Thanks George