Get record from incident that triggered the workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 09:07 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 09:30 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 10:59 PM
I have no idea
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 11:02 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 11:12 PM
Thank you
var created=current.sys_created_by;
workflow.info(current.location);
But still I cannot see any entry on workflow ?
Regards
Ashim