- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 02:48 AM
Hi, I was having one field on catalog task named 'hostname'. When this field is filled, it should auto populate the configuration item where configuration item is a reference field and hostname is single line text field. And when configuration item fills then it should also get copied on requested item form after saving the form.
But I was facing an error while doing this... Error : 'Match not found'.
Scripts are given below: Script include
var Populate_cmdb = Class.create();
Populate_cmdb.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getID: function() {
var asset = this.getParameter('sysparm_item');
if(asset != ''){
var gr = new GlideRecord('cmdb_ci_pc_hardware');
gr.addQuery('name',asset);
gr.query();
if(gr.next()){
return gr.name;
}
}
type: 'Populate_cmdb'
}
});
Client Script :
var Populate_cmdb = Class.create();
Populate_cmdb.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getID: function() {
var asset = this.getParameter('sysparm_item');
if(asset != ''){
var gr = new GlideRecord('cmdb_ci_pc_hardware');
gr.addQuery('name',asset);
gr.query();
if(gr.next()){
return gr.name;
}
}
type: 'Populate_cmdb'
}
});
}
Can anyone help with the same? I think due to reference field 'configuration item' I should capture sysid.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 03:16 AM
You should return gr.sys_id.toString();
You should also write a business rule in task table after update
var req = new GlideRecord('sc_req_item');
req.get(current.request_item.sys_id);
req.configuration_item = current.configuration_item ;// Use correct field name
req.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 03:07 AM
Hi there!
I think you missed to paste Client Script section correctly. Please update the same.
Regards,
Palak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 03:16 AM
You should return gr.sys_id.toString();
You should also write a business rule in task table after update
var req = new GlideRecord('sc_req_item');
req.get(current.request_item.sys_id);
req.configuration_item = current.configuration_item ;// Use correct field name
req.update();