Write a Script for Particular Requirement ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 03:26 AM
HostName | Home Location |
MXDD45TWX3 | Chihuahua plant |
DESKTOP-F5B8M7B | Queretaro tech |
DESKTOP-E2HNRAC | Palmela |
ksmart | Sofia |
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 04:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 04:17 AM
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???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 01:15 AM
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