- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 01:38 AM
Hi Community,
When user selects some variables values as approved from the dropdowns on catalog task, i want to check some checkboxes on the cmdb_ci form.
For e.g., if xyz is selected as approved from the dropdown list, then it should check xyz checkbox on the cmdb_ci form before closing the request.
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 10:27 PM
Hi,
it was not working because you changed the variable names for GlideRecord (you were using 'grCI' it should be 'gr1')
Try below:
else if (current.variables.oat_type == 'Database') {
var server = [];
var mrvsParsed = JSON.parse(current.variables.doat_server_details.toString());
for (var x in mrvsParsed) {
server.push(mrvsParsed[x].server_name.toString());
}
//var server = current.variables.doat_server_details.server_name.toString();
gs.log("OAT Type: Database, Server Name: " + server, "YourScriptName");
workflow.info("OAT Type: Database, Server Name: " + server);
var gr1 = new GlideRecord('cmdb_ci');
//gr1.addQuery('name', server);
gr1.addEncodedQuery('sys_idIN' + server.toString());
gr1.query();
while (gr1.next()) {
if (current.variables.privilaged_account_onboarded_to_piam_confirmation_approval == 'accept') {
//gr1.u_tpam == true;
gr1.setValue('u_tpam', true);
}
if (current.variables.database_onboarded_to_siem_confirmation_approval == 'accept') {
//gr1.u_siem == true;
gr1.setValue('u_siem', true);
}
if (current.variables.cis_scan_nessus_scan_passed_confirmation_approval == 'accept') {
//gr1.u_nessus == true;
gr1.setValue('u_nessus', true);
}
if (current.variables.ds_am_av_and_network_protect_with_ips_policy_is_set_to_prevent_or_ms_defender_installed == 'accept') {
//gr1.u_av_am_ips == true;
//gr1.u_xdr == true;
gr1.setValue('u_av_am_ips', true);
gr1.setValue('u_xdr', true);
}
gr1.update();
gs.log("Updated your_multiline_text_variable_set_table record for Database - Sys ID: " + gr1.sys_id, "YourScriptName");
workflow.info("Updated your_multiline_text_variable_set_table record for Database - Sys ID: " + gr1.sys_id);
}
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 08:46 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 08:57 PM
Yes you need to use GlideRecord query to update the cmdb_ci record.
Use GlideRecord query to get the CI record and update it,
var grCI = new GlideRecord('cmdb_ci');
grCI.addQuery('sys_id',current.variables.variable_name); // replace your field or variable to get CI sys_id
grCI.query();
if(grCI.next()){
if (current.variables.server_privilaged_account_onboarded_to_piam == 'accept') {
grCI.u_tpam == true;
}
if (current.variables.database_onboarded_to_siem_confirmation_approval == 'accept') {
grCI.u_siem == true;
}
if (current.variables.cis_scan_nessus_scan_passed_confirmation_approval == 'accept') {
grCI.u_nessus == true;
}
grCI.update();
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 09:14 PM
Hello @Poorva Bhawsar ,
I got your point like what you want to implement, also are you using workflow and it's run script activity to check and perform the action? If yes then I think am not seeing anywhere where you used the glide record to for finding and updating the record so firstly use the glide record and add the query based on your reference field to find correct record, and also at the end you need to use the gr.update(); as well so that record can get updated.
You can refer the below code and modify it according to your requirement further.
// Get the Sys ID of the related business app
var businessAppSysID = current.variables.cmdb_ci;
// Use GlideRecord to query the business app record
var gr = new GlideRecord('cmdb_ci'); // Replace with the actual table name
gr.addQuery('businessapp', businessAppSysID); // Replace 'businessapp' with the actual field name
gr.query();
if (gr.next()) {
// Check if the server privileged account is approved
if (current.variables.server_privilaged_account_onboarded_to_piam == 'accept') {
gr.u_tpam = true;
}
// Check if the database is approved
if (current.variables.database_onboarded_to_siem_confirmation_approval == 'accept') {
gr.u_siem = true;
}
// Check if the CIS scan is approved
if (current.variables.cis_scan_nessus_scan_passed_confirmation_approval == 'accept') {
gr.u_nessus = true;
}
// Update the business app record
gr.update();
}
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 10:35 PM
I have written exactly same code. But here now i have 2 cases.
1. When a field value is server.
A field will populate which is of type list collector, whatever servers user selects there. It should check checkboxes in those server records.
2. When this field value is database.
A variable set is there which contains some fields and its type is multi row. One is a reference field and other is multiple line text.
When user adds multiple records in this reference field using multi row variable set. It should check checkboxes in all those records.
Here is my code. But its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 11:31 PM - edited 12-20-2023 12:49 AM
Hello @Poorva Bhawsar ,
Please try with below code and let me know your views on this, like it works for you or not and if not then I have added some logs so check those as well so that we could get some idea exactly which part is not working.
if (current.variables.oat_type == 'Server') {
var server_name = current.variables.server_name_s;
// Logging
gs.log("OAT Type: Server, Server Name: " + server_name, "YourScriptName");
workflow.info("OAT Type: Server, Server Name: " + server_name);
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', server_name);
gr.query();
while (gr.next()) {
if (current.variables.server_privilaged_account_onboarded_to_piam == 'accept') {
gr.u_tpam = true;
}
if (current.variables.database_onboarded_to_siem_confirmation_approval == 'accept') {
gr.u_siem = true;
}
if (current.variables.cis_scan_nessus_scan_passed_confirmation_approval == 'accept') {
gr.u_nessus = true;
}
if (current.variables.ds_am_av_and_network_protect_with_ips_policy_is_set_to_prevent_or_ms_defender_installed == 'accept') {
gr.u_av_am_ips = true;
gr.u_xdr = true;
}
gr.update();
// Logging
gs.log("Updated cmdb_ci record for Server - Sys ID: " + gr.sys_id, "YourScriptName");
workflow.info("Updated cmdb_ci record for Server - Sys ID: " + gr.sys_id);
}
} else if (current.variables.oat_type == 'Database') {
var server = current.variables.server_name;
// Logging
gs.log("OAT Type: Database, Server Name: " + server, "YourScriptName");
workflow.info("OAT Type: Database, Server Name: " + server);
var gr1 = new GlideRecord('your_multiline_text_variable_set_table'); // Replace with the actual table name for your multi-row variable set
gr1.addQuery('reference_field', server); // Replace 'reference_field' with the actual reference field name
gr1.query();
while (gr1.next()) {
if (current.variables.server_privilaged_account_onboarded_to_piam == 'accept') {
gr1.u_tpam = true;
}
if (current.variables.database_onboarded_to_siem_confirmation_approval == 'accept') {
gr1.u_siem = true;
}
if (current.variables.cis_scan_nessus_scan_passed_confirmation_approval == 'accept') {
gr1.u_nessus = true;
}
if (current.variables.ds_am_av_and_network_protect_with_ips_policy_is_set_to_prevent_or_ms_defender_installed == 'accept') {
gr1.u_av_am_ips = true;
gr1.u_xdr = true;
}
gr1.update();
// Logging
gs.log("Updated your_multiline_text_variable_set_table record for Database - Sys ID: " + gr1.sys_id, "YourScriptName");
workflow.info("Updated your_multiline_text_variable_set_table record for Database - Sys ID: " + gr1.sys_id);
}
}
Also make sure to format your code with reference to the below sample code where you are using the variables which are in MRVS.
var mrvs = current.variables.employee_details; // employee_details is my MRVS name make sure to replace it with yours
var first_name = mrvs[0].first_name; // first_name is my variable from the MRVS so make sure to replace this variable as well with yours and use the same syntax in the above script where you are trying to use/access the variables from MRVS
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket