- 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 02:29 AM
HI,
Show me your code?
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 06:55 AM
please find the script below
var gr = new GlideRecord('u_posts');
gr.initialize();
gr.pos_desc = workflow.scratchpad.desc;
gr.pos_type = workflow.scratchpad.type;
gr.insertWithReferences();
var id = gr.insert():
var mem = new GlideRecord('u_posts');
gr.addQuery('sys_id', id);
workflow.scratchpad.number = mem.u_number;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 11:31 PM
HI,
Use below Script:
var gr = new GlideRecord('u_posts');
gr.initialize();
gr.pos_desc = workflow.scratchpad.desc;
gr.pos_type = workflow.scratchpad.type;
gr.insertWithReferences();
var id = gr.insert():
var mem = new GlideRecord('u_posts');
mem.addQuery('sys_id', id);
mem.query();
mem.next();
workflow.scratchpad.number = mem.u_number;
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2018 07:17 PM
I tried with your script,
Still record is inserting 2 times(duplicate)
if I remove below script, it is inserting only one time
var id = gr.insert():
var mem = new GlideRecord('u_posts');
mem.addQuery('sys_id', id);
mem.query();
mem.next();
workflow.scratchpad.number = mem.u_number;
please suggest

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2018 09:10 PM
HI,
I Know why!
Use below script now. We are insert it twice using gr.insert and gr.insertWithReference
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 = mem.u_number;
Thanks,
Ashutosh