- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 12:43 AM
Hi All,
How can we pass created record value into workflow scratch pad.
I am creating a record via catalog item workflow script and once the record is created, number will be auto generated in table.
I want to pass generated number into my same workflow scratch pad in next activity.
can anyone suggest me with the script please.
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 01:17 AM
HI,
This is the problem, You are trying to set reference field with String or Number value and that will not work here.
What should you do it save sys_id in scratchpad and use that to save it to u_position field. And That u_post table should have display value true for Number field. hence it will show number automatically there. Use below code:
var gr = new GlideRecord('u_posts');
gr.initialize();
gr.pos_desc = workflow.scratchpad.desc;
gr.pos_type = workflow.scratchpad.type;
var id = gr.insertWithReferences();
//var mem = new GlideRecord('u_posts');
//mem.addQuery('sys_id', id);
//mem.query();
//mem.next();
workflow.scratchpad.number = id;
And the use this scratchpad. This will show you record in this u_position field as this is a reference field.
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 12:49 AM
Hi,
We use workflow scratchpad as below:
Suppose you have created a Record using script you might have a use var id = gr.insert(); where id will store sys id of newly created record.
Then you will have to gliderecord that table to fetch number of newly created record.
and get that number and store in workflow as below:
workflow.scratchpad.num = gr.number;
Then where ever you want to access this you can directly use workflow.scratchpad.num to assign or use number.
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 12:52 AM
HI,
See below links:
https://docs.servicenow.com/bundle/helsinki-servicenow-platform/page/administer/using-workflows/concept/c_WorkflowScratchpadVariables.html
https://community.servicenow.com/community?id=community_question&sys_id=05660be1db1cdbc01dcaf3231f96196c
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 01:23 AM
HI Ashtosh,
My number will generate after inserting the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 01:48 AM
if i user var id = gr.insert();
record is inserting 2 times