Get record from incident that triggered the workflow

Ashim Thapa
Tera Contributor

Hi,

I am new to ServiceNow. I have created a workflow that triggers on whenever priority changes to 1 of the incident. Then it runs a script. The code in the script is failing to get the current record that triggered the workflow. This is my script for testing :

workflow.info("start");
workflow.info(current.variables.sys_created_by);
var created=current.sys_created_by;
gs.info(created);
workflow.info(created);
workflow.info(current.assignment_group);

//current.getValue(fieldName);

var location=current.Location;
workflow.info(location);

No issues with triggering the workflow but I am not finding any current value in workflow log. Please help me on how to use the current, to get the record that triggered this workflow.

 

Thanks.

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

are you sure this line is valid?

workflow.info("start");
workflow.info(current.variables.sys_created_by);
var created=current.sys_created_by;
gs.info(created);
workflow.info(created);
workflow.info(current.assignment_group);

//current.getValue(fieldName);

var location=current.location; // it should be location and not Location
workflow.info(location);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ashim Thapa
Tera Contributor

I have no idea @Ankur Bawiskar

I just tried few codes that I saw while searching. No idea what is difference between current.field_name and current.variables. But even the line current.sys_created_by is not working.

Regards

Ashim

Hi,

current.fieldName will give you field value

if the record has variables associated then you can use this to access variable value

current.variables.variableName

current.sys_created_by should work fine

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thank you @Ankur Bawiskar for clarification. I have removed that line. Have changed my code to just below two lines.