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

No comments:

Post a Comment

Discovery troubleshooting | Error messages

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