The CreatorCon Call for Content is officially open! Get started here.

Set table record

servicenow14710
Tera Expert

How to get custom table record from previous run script of workflow which we have inserted

eg: insertion of record in custom table:

var gr = new GlideRecord('u_c_table');
gr.initialize();
gr.u_requested_for = current.variables.user;
gr.u_status = 'waiting for approval';
gr.u_date = gs.nowDateTime();
gr.insert();

 

 

I need to update this records status in next run script of workflow, Any help is appreciated. Thanks!

1 ACCEPTED SOLUTION

piyushsain
Tera Guru

Hi @servicenow14710 

For this you can use workflow scratchpad, the workflow scratchpad is available throughout the workflow cycle. So in your script you can try this 

var gr = new GlideRecord('u_c_table');
gr.initialize();
gr.u_requested_for = current.variables.user;
gr.u_status = 'waiting for approval';
gr.u_date = gs.nowDateTime();
gr.insert();
workflow.scratchpad.recordID= gr.sys_id;

now in another script or activity you can use this scratchpad.

 

Link https://docs.servicenow.com/de-DE/bundle/sandiego-it-operations-management/page/administer/using-wor...

https://www.servicenow.com/community/itsm-forum/workflow-scratchpad/m-p/509877

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

View solution in original post

1 REPLY 1

piyushsain
Tera Guru

Hi @servicenow14710 

For this you can use workflow scratchpad, the workflow scratchpad is available throughout the workflow cycle. So in your script you can try this 

var gr = new GlideRecord('u_c_table');
gr.initialize();
gr.u_requested_for = current.variables.user;
gr.u_status = 'waiting for approval';
gr.u_date = gs.nowDateTime();
gr.insert();
workflow.scratchpad.recordID= gr.sys_id;

now in another script or activity you can use this scratchpad.

 

Link https://docs.servicenow.com/de-DE/bundle/sandiego-it-operations-management/page/administer/using-wor...

https://www.servicenow.com/community/itsm-forum/workflow-scratchpad/m-p/509877

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain