How to get the workflow context sys_id in the workflow for run script activity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 04:44 AM
Hi,
I need to populate the u_context (referenced to wf_context) in the run script activity of the workflow,
but would need a way to get this into the workflow, any inputs?
- Labels:
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 05:17 AM
Hi,
You can add this script in your activity to get workflow context sys_id.
var id = '';
var gr = new GlideRecord('wf_context');
if(gr.get("id", current.sys_id)){
id = gr.sys_id;
}
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2017 01:03 AM
Hi Naga,
Have you tried to execute this script?
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2017 03:26 AM
I used this script to get it working , but it would fail when there is more than one workflow running on the record so I wrote a BR on wf_context to trigger on particular condition to update the "id" 's "u_context" from the wf_context record, but seems its failing for no reason.
After Insert BR on wf_context table:
var gr = new GlideRecord("u_custom_table");
if(gr.get(current.id)){
gr.u_context = current.sys_id;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2017 04:02 AM
What are you trying to achieve? A record can only have single workflow context at a time.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response