Asset Name Auto Populate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2025 11:13 PM
@IN Incident table for a newly created field called Asset Name. How can I auto populate the Asset Name with the corresponding asset from the cmdb_ci_computer table whenever the 'Configuration Item' field is filled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2025 11:00 PM
Hi @SATYAP ,
you can try below ways
1. without script and without creating new field : open incident form right click Configure > form layout search the Configuration item then click on expand icon
then after that it will show all the configuration item fields select the asset push to selected
then it will populate the assets whenever you select the cmdb_ci_computer records in Configuration Item' field.
2. With Script:
Client script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('GetAssetInfo'); // GetAssetInfois the script include name
ga.addParam('sysparm_name','getAssetName');
ga.addParam('sysparm_ci_name',newValue); // set ci value
/* Call GetUserInfo.managerName() with user set to Fred Luddy and use the callback function ManagerParse() to return the result when ready */
ga.getXMLAnswer(AssetName);
}
function AssetName(response) {
g_form.setValue('u_asset_name',response);// newly created field name 'u_asset_name'
}
Script include:
var GetAssetInfo= Class.create();
GetAssetInfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getAssetName: function() {
var ciName = this.getParameter("sysparm_ci_name");
var grCi = new GlideRecord('cmdb_ci_computer');
grCi .get("sys_id", ciName );
// Build the payload. You can return additional data if needed.
var result = {
"asset": grCi.getDisplayValue('asset')
};
return JSON.stringify(result);
},
type: 'GetAssetInfo'
});
If this information proves useful, kindly mark it as helpful or accepted solution.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2025 11:16 PM
Why do you want this custom field?
2 ways
1) either show dot walked field on from from that reference field
OR
2) create new field and populate using onChange client script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader