Wednesday, October 31, 2018

Insert a Record in a table through Script

1. Initialize the variable
2. Use insert function to insert the record into the table.

hardwarediffArray = netcoolid.filter(function(obj) { return concatarray.indexOf(obj) == -1; }); 
gs.log('hardwarediffArray Count--->' +hardwarediffArray.length); 


var delta_table = new GlideRecord('u_delta_of_eedb_and_hardware');
var i=0;
var array='';
gs.log('hardwaresize------>'+hardwarediffArray.length);
while(i<hardwarediffArray.length){
delta_table.initialize();
delta_table.u_netcool_id_cmdb=hardwarediffArray[i];
delta_table.u_is_it_in_cmdb=true;
delta_table.u_is_it_in_eedb=false;
var hdw = new GlideRecord('cmdb_ci_hardware');
hdw.addQuery('u_netcool_id',delta_table.u_netcool_id_cmdb);
hdw.query();
while(hdw.next())
{
delta_table.u_functional_type = hdw.u_functional_type;
delta_table.u_host_name_cmdb = hdw.name;
delta_table.u_ip_address_cmdb = hdw.ip_address;
}
delta_table.insert();
i++;
}

Update a Record in a table through script


  • Use update function to update the record on a table.
  • Update Choice field and true/false field.



var querystring = 'name=belle-uc-***';

var op = new GlideRecord('cmdb_ci_hardware');
op.addEncodedQuery(querystring);
op.query();
while(op.next())
{

gs.log('operation status -->' +op.operational_status.getDisplayValue());
gs.log('Monitor-->' +op.monitor);
gs.log('category-->' +op.category);

//Operational status is a choice field. So, pass value in setting
//Monitor is a true / false field

op.operational_status = "4";
op.monitor = "false";
op.category = "testing"
op.update();

gs.log('operation status -->' +op.operational_status.getDisplayValue());
gs.log('Monitor-->' +op.monitor);
gs.log('category-->' +op.category);

}

Before script is executed:



After script is executed:







Make variable type - Label as Bold

1. Create an OnLoad Catalog Client script

2. Script -->

function onLoad() {
   //Type appropriate comment here, and begin script below
// alert('variable set');
   g_form.getControl('u_app_details_label').setAttribute('style', 'font-weight:bold;font-size:15px');
}



Discovery troubleshooting | Error messages

  Discovery troubleshooting | Error messages - Support and Troubleshooting (servicenow.com) Description Learn how to resolve common Discover...