How to checked two check box fields for different fields based on condition?

ramuv
Tera Expert

How to checked two check box fields for different fields based on condition?

Scenario:

We have two fields 1. field1 check box created on incident form.

                                  2. field2 check box created on  cmdb_ci_computer table(form)

when we selected configuration item on incident form based on that two check boxes checked.

i wrote before business rule , Please correct  me where i did mistake or Please provide any other solution. 

Table : incident , condition : configuration item is not empty.

        current.u_critical_ci = true;
    //current.getTableName.cmdb_ci_computer.u_critical_ci1 =true;
        current.sys_class_name.cmdb_ci_computer.u_critical_ci1 = true;
Thanks

 

 

 

 

1 ACCEPTED SOLUTION

Yashsvi
Kilo Sage

Hi @ramuv,

Please try  this BR:

 

 

// Check if the configuration item is selected and is a computer
if (!gs.nil(current.cmdb_ci)) {
    // Set the u_critical_ci checkbox on the incident
    current.u_critical_ci = true;

    // Query the cmdb_ci_computer table for the selected configuration item
    var ciGr = new GlideRecord('cmdb_ci_computer');
    if (ciGr.get(current.cmdb_ci)) {
        // Set the u_critical_ci1 checkbox on the cmdb_ci_computer record
        ciGr.u_critical_ci1 = true;
        ciGr.update();
    }
}

 

 

 

  • Make sure that cmdb_ci is pointing to the correct configuration item and that the item is of type cmdb_ci_computer.
  • Ensure that the field names u_critical_ci and u_critical_ci1 are correctly spelled and exist on their respective tables.

Thank you, please make helpful if you accept the solution. 

 

View solution in original post

1 REPLY 1

Yashsvi
Kilo Sage

Hi @ramuv,

Please try  this BR:

 

 

// Check if the configuration item is selected and is a computer
if (!gs.nil(current.cmdb_ci)) {
    // Set the u_critical_ci checkbox on the incident
    current.u_critical_ci = true;

    // Query the cmdb_ci_computer table for the selected configuration item
    var ciGr = new GlideRecord('cmdb_ci_computer');
    if (ciGr.get(current.cmdb_ci)) {
        // Set the u_critical_ci1 checkbox on the cmdb_ci_computer record
        ciGr.u_critical_ci1 = true;
        ciGr.update();
    }
}

 

 

 

  • Make sure that cmdb_ci is pointing to the correct configuration item and that the item is of type cmdb_ci_computer.
  • Ensure that the field names u_critical_ci and u_critical_ci1 are correctly spelled and exist on their respective tables.

Thank you, please make helpful if you accept the solution.