
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 03:49 AM - edited 02-06-2024 03:59 AM
Hi,
Here is a form that users need to fill out. Once the caller field is populated, the machine name and IP address fields should auto-populate, but its not happening. I'm not sure why. Any assistance would be appreciated.
script include:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 06:22 AM
Hi @Community Alums ,
Please refer to the below script and make the change in query condition as per your requirement:
ScriptInclude:
=================================================================================
Client Script:
Please hit the like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.
Thanks & Regards
Jyoti Jadhav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 03:55 AM
Hi @Community Alums the below line is wrong in your script include
ast.addQuery("sys_class_name", "sysid");// here your looking for class name of CI, but you have put "sysid"
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 04:01 AM
Updated , added the actual class sysid which is "computer".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 04:00 AM - edited 02-06-2024 04:01 AM
Hi @Community Alums here is the updated code
getIPandMachineName: function() {
var assetDetails = {};
var req = this.getParameter("sysparm_user");
var ast = new GlideRecord("cmdb_ci_hardware");
// ast.addQuery("sys_class_name", "sysid"); // invalid query
ast.addQuery("assigned_to", req);
ast.addQuery("install_status", 1);
ast.query();
if (!ast.hasNext()) {
return "No Record Found";
} else {
while (ast.next()) {
assetDetails.machine_name= ast.getValue('name');
assetDetails.ip_address = ast.getValue('ip_address');
}
var answer = JSON.stringify(assetDetails);
return answer;
}
},
client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var caller = g_form.getValue('caller_id');
var ga = new GlideAjax("machineDetails");
ga.addParam("sysparm_name", "getIPandMachineName");
ga.addParam("sysparm_user",newValue);
ga.getXMLAnswer(setalert);
function setalert(answer){
alert(JSON.stringify(answer,null,4));
g_form.setValue('machine_name', answer.machine_name);
g_form.setValue('ip_address', answer.ip_address);
}
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 04:15 AM
still doesn't populate the machine name and ip address field.
Regards
C