How to get the workflow context sys_id in the workflow for run script activity.

nagapramodkanch
Kilo Guru

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?

11 REPLIES 11

Alikutty A
Tera Sage

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


Hi Naga,



Have you tried to execute this script?



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


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();


}


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