Write a Script for Particular Requirement ?

1dusjhyahnt
Tera Contributor
HostNameHome Location
MXDD45TWX3Chihuahua plant
DESKTOP-F5B8M7BQueretaro tech
DESKTOP-E2HNRACPalmela
ksmartSofia

 

Table Name:- u_auto_update_last_communication_date.

Field Name:- Hostname= u_hostname.

HomeLocation:- u_home_location.

Requirement :- Write a script for mapping the hostname with particular location in servicenow?

3 REPLIES 3

Mark Manders
Mega Patron

This is not a requirement. This is providing way to less information to even get a slight comprehension of what it is you are trying to accomplish.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

hi @Mark Manders 

 

var grUAULCD = new GlideRecord('u_auto_update_last_communication_date');
var hostname= grUAULCD.addEncodedQuery("u_hostname=PTD5YKJ992");
grUAULCD.orderBy('null');
grUAULCD.setLimit(100);
grUAULCD.query();
while (grUAULCD.next()) {
   grUAULCD.setDisplayValue('u_home_location',  'ALBA');
   grUAULCD.setWorkflow(false);
   grUAULCD.update();
   
}

 

I want to modify the script for mapping the different   location with different hostname???

You could try this: 

var locationMapping = {
    'MXDD45TWX3': 'Chihuahua plant',
    'DESKTOP-F5B8M7B': 'Queretaro tech',
    'DESKTOP-E2HNRAC': 'Palmela',
    'ksmart': 'Sofia'
};
var grUAULCD = new GlideRecord('u_auto_update_last_communication_date');
grUAULCD.setLimit(100);
grUAULCD.query();
while (grUAULCD.next()) {
   grUAULCD.setDisplayValue('u_home_location',  locationMapping[grUAULCD.u_host_name]);
   grUAULCD.setWorkflow(false);
   grUAULCD.update();
   
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark