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

HI Ashutosh,

Thanks for the reply.

now it is capturing in scratch pad. 

Now the value is coming in list view but if I open the record, field value is blank

 find_real_file.png

 

 find_real_file.png

HI,


We are not setting this field anywhere which you have highlighted.

We are only moving it to scratchpad. Where are you setting this field can you tell me?


Thanks,
Ashutosh Munot

HI,

 

If your work is done close this thread by marking answer as helpful or correct.


Thanks,
Ashutosh

HI Ashutosh,

 

we are setting number to scratchpad and in next run script I am setting this value. Please find my script below

 

workflow.scratchpad.number = mem.u_number;

 

 

 

var gr = new GlideRecord("sys_user");
gr.addEncodedQuery("sys_idIN"+current.variables.user);
gr.query();

var gr_names = "";

while (gr.next()) {

var grm = new GlideRecord('u_user_post');
grm.initialize();

grm.u_position = workflow.scratchpad.number;
grm.u_active = 'true';
grm.u_user=gr.sys_id;
grm.query();
grm.insert();

//grm.insertWithReferences();


}

HI,

 

Can you tell me type of this field?

 

grm.u_position

Thanks,
Ashutosh Munot