How to fetch current workflow sys id when creating custom activities?
This content was last updated in 2017. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 03:07 PM
Hello,
I am creating a custom activity and would like to fetch the current workflow id in which the user uses the activity from within the activity pack. I tried the following in a run script custom activity under ServiceNow orchestration:
var gr = new GlideRecord('wf_context');
gr.addQuery('id',current.sys_id);
gr.query();
this is throwing me "current not defined" error.
Any idea how I can fetch current workflow sys id when creating custom activities?
thank you
Swetha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 03:38 PM
Hi Shwetha,
Check section 3.15.3 from the below link if it helps.
Workflow Script - ServiceNow Wiki
Else check below code from thread...Re: Workflow creation
var s = new GlideRecord('wf_workflow');
s.addQuery('name', '<workflow_name>');
s.query();
if (s.next()) {
var workflowId = '' + s.sys_id;
}
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 03:42 PM
I would like to fetch the sys id without entering the workflow name details as im trying to generate a generic script that reads the current sys_id details and perform certain actions specific to that id