To copy variable's value into a journal type field

Poorva Bhawsar
Mega Sage

Hi Community,

 

I have few select box variables, if user selects the value of those variables as rejected, rejection reason field will populate. I want to copy the value of those variables if they are rejected along with the rejection reason from sctask to another table's journal type field.

 

I am thinking about the logic like if xyz == rejected && rejection reason != '' then need to add them in that journal field. If those are not rejected, those i approved i dont want to add them in this journal field.

 

Thanks,

Poorva Bhawsar

 

1 ACCEPTED SOLUTION

Hi @Poorva Bhawsar the error is below

var answer = [];
var server_name = current.variables.server_name_s.toString();
var arr = server_name.split(',');
for (var i = 0; i < arr.length; ++i) {
var grCI = new GlideRecord('cmdb_ci_server');
grCI.addEncodedQuery('sys_idIN' + server_name.toString());//replace to arr[i]

to

grCI.addEncodedQuery('sys_idIN' + arr[i]);
grCI.query();
while (grCI.next()) {
//gs.log("Inside the l

Regards
Harish

View solution in original post

35 REPLIES 35

Harish KM
Kilo Patron
Kilo Patron

Hi @Poorva Bhawsar you can do like you said, to check the value of variable in BR you can do like this

if(current.variables.xyz == 'rejected' && current.rejection_reason !='')

{

//glide another table to pass the values to journal field.

}

 

Regards
Harish

This logic i already told but how to pass those values that i need.

Hi @Poorva Bhawsar  assuming your BR is on sc task table with before update checked

sample script:

if(current.variables.xyz == 'rejected' && current.rejection_reason !='')

{

var gr = new GlideRecord('tablename');

gr.addQuery('parent',current.sys_id); // parent is the field on the table which holds reference to sc task table

gr.query();

if(gr.next())

{

gr.comments = "Rejected Reason :"+current.variables.variablename +'<br>'+ "Reason": +current.fieldname;

}

 

}

Regards
Harish

I have multiple variables. Do i need to gliderecord for all or i need to loop for that?