Output of gs.log from Workflow Run Script

Arijit6
Kilo Contributor

Hi I am trying to debug the follwoing code by trying to determine the location value. I have used a gs.log statement, however when I try to check the 'script log statements' and search for the string "ABCD" I don't find anything. Can you please advise how to check the output of the gs.log as I am trying to see what value is returned.

 

//var getServiceString = current.variables.server_name.toString();
//var getServiceArray = getServiceString.split(",");

var taskList=[];
{
var description = 'Requested For: '+current.variables.requested_for.name +'\n ';


//gs.print('VMP provisioning - i '+(getServiceArray[i]).trim());
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.request =current.request;
gr.request =current.request;
gr.request_item = current.sys_id;
gr.short_description = 'Approved WFH Kit Review and Fulfilment Task ';
gr.description = 'A WFH Kit reimbursement request has been approved. Please Review and Fulfil this request';
gs.log('TEST ABCDEF '+current.variables.requested_for.location.country);
if(current.variables.requested_for_country == 'PH')
{
gr.assignment_group='9b9aa55fdb9e2c5098a059364a961985';
gr.assigned_to ='e90c60e8db2207003fbd788bbf96196f';
}
else if(current.variables.requested_for_country != 'PH')
{
gr.assignment_group='6f041e72db62a0140450e4e38a9619bb';
gr.assigned_to ='cdebe2dddb5613408c37325d7c9619e2';
}
gr.state=3;
var getTask = gr.insert();
taskList.push(getTask);
//gr.state=3;
//gr.update();
}

workflow.scratchpad.task=(taskList).toString();

 

7 REPLIES 7

AnirudhKumar
Mega Sage
Mega Sage

Your script looks good...

Is you workflow running in scoped app?

Anyway, always use gs.info()... It works everywhere.

Here's what I do to check log messages.

Suppose my log message is like this:

gs.info('test@@ - ' + current.variables.user);

 

- I type logs in the navigator, and go to System Log -> All

- In the Message column, I search for *test@@

 

find_real_file.png

Hi Anirudh,

I still dont get any output in System Log - All with below. I checked under Messages for 'Test ABCDEF', but doesnt retrun anything.

//var getServiceString = current.variables.server_name.toString();
//var getServiceArray = getServiceString.split(",");

var taskList=[];
{
var description = 'Requested For: '+current.variables.requested_for.name +'\n ';


//gs.print('VMP provisioning - i '+(getServiceArray[i]).trim());
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.request =current.request;
gr.request =current.request;
gr.request_item = current.sys_id;
gr.short_description = 'Approved WFH Kit Review and Fulfilment Task ';
gr.description = 'A WFH Kit reimbursement request has been approved. Please Review and Fulfil this request';
gs.info('TEST ABCDEF');
if(current.variables.requested_for_country == 'PH')
{
gr.assignment_group='9b9aa55fdb9e2c5098a059364a961985';
gr.assigned_to ='e90c60e8db2207003fbd788bbf96196f';
}
else if(current.variables.requested_for_country != 'PH')
{
gr.assignment_group='6f041e72db62a0140450e4e38a9619bb';
gr.assigned_to ='cdebe2dddb5613408c37325d7c9619e2';
}
gr.state=3;
var getTask = gr.insert();
taskList.push(getTask);
//gr.state=3;
//gr.update();
}

workflow.scratchpad.task=(taskList).toString();

 

 

 

Tony Chatfield1
Kilo Patron

Hi, I would expect to see the logging details in Script Log Statements.

I would suggest you start with a plain text logging entry as the first line in your code.
gs.info('My script is running');
This will confirm that the script is running, which is the first step in diagnostics – never assume anything.
Also any log statement involving a variable might fail if the var didn’t exist or your previous code or var call is malformed, so start at top of your code and work downwards.
when it comes to debug logging, more is always better (except in prod)

Hi Tony, I still don't get any results in my script log statement, even after removing any variables.

var taskList=[];
{
var description = 'Requested For: '+current.variables.requested_for.name +'\n ';


//gs.print('VMP provisioning - i '+(getServiceArray[i]).trim());
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.request =current.request;
gr.request =current.request;
gr.request_item = current.sys_id;
gr.short_description = 'Approved WFH Kit Review and Fulfilment Task ';
gr.description = 'A WFH Kit reimbursement request has been approved. Please Review and Fulfil this request';
gs.info('TEST ABCDEF');
if(current.variables.requested_for_country == 'PH')
{
gr.assignment_group='9b9aa55fdb9e2c5098a059364a961985';
gr.assigned_to ='e90c60e8db2207003fbd788bbf96196f';
}
else if(current.variables.requested_for_country != 'PH')
{
gr.assignment_group='6f041e72db62a0140450e4e38a9619bb';
gr.assigned_to ='cdebe2dddb5613408c37325d7c9619e2';
}
gr.state=3;
var getTask = gr.insert();
taskList.push(getTask);
//gr.state=3;
//gr.update();
}

workflow.scratchpad.task=(taskList).toString();

 

 

find_real_file.png