How to get workflow context id, inside a custom activity where this activity is used
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2016 03:05 AM
I have a created a custom activity of type run script ,
and calling a Rest Message post function
var sm = new sn_ws.RESTMessageV2("ABC","post");
var url= "https://<instance name>/api/<namespace>/"+workflow.getUniqueValue();
And passing this as request body to the rest message.
I need the context id of the workflow in which this custom activity gets included in.
But when i run the workflow in which this custom activity gets included, i get error message --> workflow is not defined.
Any idea how to get workflow context sys id within the custom activity?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2016 02:46 PM
Anyone has any idea to share here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2016 07:06 PM
You would access it from a Run Script inside the workflow as:
var workflowContextID = current.context.sys_id;
Please mark this post helpful and/or answered if you found it as such.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2016 11:33 AM
current.context.sys_id doesn't seem to work in Helsinki when ran in a Run Script activity.
current.getTableName() return wf_workflow_execution as the table. This table doesn't have the context field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 03:47 AM
Late to the party...
current.context will work IF there is a context reference field on your table that has something in it.
Have a look at tables and columns..context field is on the base task table and so suggest extending from that to get the field and what ever populates it..BR probably.
http://wiki.servicenow.com/index.php?title=Workflow_Script#cancelContext.28context.29&gsc.tab=0