- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 10:52 PM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 12:13 AM
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
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:37 PM - edited 01-29-2024 09:50 PM
You can add all the variables inside if condition, no need to gliderecord again.
example:
gr.u_deviation_notes += "Requested Number: " + current.variables.number, "Rejected Reason :" + current.variables.rejection_reason3 +'<br>'+ "Failed :" + current.vendor_support_in_place_approval ;
if (current.variables.shutdown_started_tested_approval == 'failed' && current.variables.rejection_reason9 != '')
gr.u_deviation_notes += +current.variables.rejection_reason9;
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 11:55 PM
But i have multiple if conditions and for multiple if conditions i want to add deviation notes as different for all. According to the code you have given, under if condition i need to gliderecord that. But what if i have multiple if conditions. How it will work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 12:09 AM - edited 01-31-2024 12:10 AM
Hi @Poorva Bhawsar you can concatenate like this
var gr = new GlideRecord('tablename'); //table you want to copy variable value
gr.addQuery('parent', current.sys_id); // parent field from your table holds sc task sysID
gr.query();
if(gr.next()){
gr.u_deviation_notes += "Requested Number: " + current.variables.number, "Rejected Reason :" + current.variables.rejection_reason3 +'<br>'+ "Failed :" + current.vendor_support_in_place_approval;
if(cond1)
gr.u_deviation_notes += "Variable Question: " + current.variables.variablename;
if(cond2)
gr.u_deviation_notes += "Variable Question: " + current.variables.variablename;
if(cond3)
gr.u_deviation_notes += "Variable Question: " + current.variables.variablename;
gr.update();
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 01:46 AM
I am doing exactly same now. But its not updating the deviation notes field.
Here is the updated code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 02:03 AM
Hi @Poorva Bhawsar your code is not working because on cmdb_ci_server table we donot have a field called "parent", so the code is failing, the below line
gr.addQuery('parent', current.sys_id); // you need to pass correct field name here, parent field is invalid
Harish