glide created record and store field value in workflow scratchpad

Hitesh targe
Tera Expert

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

1 ACCEPTED SOLUTION

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

 

 

View solution in original post

21 REPLIES 21

This is reference field to u_posts and number (u_number) from u_posts will save in u_position.

 

 

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

 

 

works perfect.

 

Thank you verymuch for your help

Hi Hitesh,

 

You can use script as mentioned below

var gr = new GlideRecord('u_posts');
gr.initialize();
gr.pos_desc = workflow.scratchpad.desc;
gr.pos_type = workflow.scratchpad.type;

var id = gr.insert();

 

workflow.scratchpad.number = gr.u_number;

You need not to glide again.

 

Hope this helps.

 

Regards

Ujjawal

We tried this but Here number is generating after inserting the record.