To check checkboxes based on field values

Poorva Bhawsar
Mega Sage

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

1 ACCEPTED SOLUTION

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);
        }
    }

  

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

34 REPLIES 34

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Poorva Bhawsar 

 

Greetings!!

 

This can be done via Flow Designer. In check the variable values and in script, go to cmbd_ci table and set the value.

 

Please try your hands and share the code / screen shot or error message where you stuck.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Aniket Chavan
Tera Sage
Tera Sage

Hello @Poorva Bhawsar 

You can achieve this by using either workflow or flow designer by checking the variable values in if conditions and if the condition matches with your requirement you can use the run script activity if you're using workflow and after that you can make whatever the changes you want in your desired target table which is cmdb_ci.

Or also you can apply business rule as well on after insert or update and in that configure the trigger conditions by using your task field like short description and also check the variables and there condition as well and then if those matches then you can gilde to cmdb_ci form and update the record.

 

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

Hi @Aniket Chavan,

I am already checking those variables values as accept or not using if condition but i am not getting how i will check those checkboxes on server table.

Do i need to gliderecord it on the server table? What logic i need to apply?

Thanks

Hello @Poorva Bhawsar ,

Can you share the details like exactly what you are using flow or workflow in which you are checking the variable and exactly which point you are stuck at? So that I can try to help you accordingly.

Thanks,
Aniket.