How to access the record producer variable

ramesh_r
Mega Sage

Hi All,

I have created the record producer and i selected the target table as "remediation_rule" and once I submitted the record procedure the record is getting created in the "remediation_rule" table. and i am trying to get the variable value using the below script but it's not working as expected

Variable will access only Incident change table like that ..? becase the same log working in those table

 

var gr = new GlideRecord('remediation_rule');
gr.addQuery('sys_id', 'ae4d693a2fdf011009d159ab2799b693');
gr.query();
if(gr.next()){
var name = gr.variables.test;

gs.info(name);

}

1 ACCEPTED SOLUTION

Can you check if there is an entry in question_answer table once for the submitted record with required values.

View solution in original post

13 REPLIES 13

Musab Rasheed
Tera Sage
Tera Sage

Hi @ramesh.r ,

If you want to set field to record producer variable you can directly do in record producer form in 'Script' section by writing simple code like below. Mark my answer as correct if this is what you are looking for.

current.name = producer.test;

Regards

 

Please hit like and mark my response as correct if that helps
Regards,
Musab

Hi,

I don't want to set any field. i just want have in the variable only and need to access using script

Thanks

Ramesh R

Dibyaratnam
Tera Sage
Hi Ramesh,
 
Can you check below script.
<GlideRecord>.variables.<variablename> will work only for Record producer variables.
 
var grInc = new GlideRecord('incident');
grInc.addQuery('number','INC0010082');
grInc.query();
while(grInc.next()){
gs.info(grInc.variables.state);
gs.info(grInc.getValue('state'));
var name = grInc.variables.comments;
gs.info(name);
}
 
 
On execution:
*** Script: undefined
*** Script: 1
*** Script: Please test

Hi 

 

for the incident table, its working fine but I have created a record producer on a different table (Ex: remediation_rule)

I am trying to get the value in the above table but it's not working.

 

Thanks

Ramesh R