- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2022 08:34 AM
Hi All,
I have created a record producer which currently returns assets assigned to the current user. (see below)
What I am trying to do is pull the associated configuration item off the record that exists for those assets. for example the P1000104 - Apple iMac 27" has an associated CI: Apple iMac 27" - CI
The purpose is so that the CI is automatically populated on the incident record which is created when the record producer is submitted.
I have tried doing this from the scripting area on the record producer and had no joy.
I have started trying to create a client script and script include but I haven't been able to get it working. please see the below code:
Catalog client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var citem = new GlideAjax('assetci'); //Name of the Script Include
citem.addParam('sysparm_name', 'getci'); //name of function in script include
citem.addParam('sysparm_conf', g_form.getValue('what_do_you_have_an_issue_with'));
//alert(g_form.getUniqueValue('what_do_you_have_an_issue_with'));
citem.getXML(confCallback);
function confCallback(response) {
var coni = response.responseXML.documentElement.getAttribute("answer");
alert(coni);
g_form.setValue('coni');
}}
Script include:
try {
var assetci = Class.create();
assetci.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getci: function() {
gs.error('getci has been called');
var conf = this.getParameter('sysparm_conf');
var confGR = new GlideRecord('alm_asset');
confGR.addQuery('ci', conf);
confGR.query();
gs.error(conf);
if (confGR.next()) {
gs.error(confGR.ci.getDisplayValue());
return confGR.ci.getDisplayValue();
}
},
type: 'assetci'
});
} catch (err) {
gs.error('[' + gs.getCurrentScopeName() + ']' + ': assetci: get config item - Caught error: ' + err);
}
The gs.error is returning undefined in the script include.
Any help would be amazing
Thanks
Alex
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2022 11:29 AM
Hi Alex,
Use the following script in the script field of record producer;
var gr = new GlideRecord('alm_asset');
if(gr.get(producer.what_do_you_have_an_issue_with)) //I am assuming that 'producer.what_do_you_have_an_issue_with' will return sys_id of record in alm_asset.
current.cmdb_ci = gr.getValue('ci'); // Populating cmdb_ci field of the incident table with ci field of alm_asset table.
Hopefully this will work for you as it is working on my PDI.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2022 11:24 AM
Hi there,
No need to use catalog client script or script include here. You can simply use the record producer's script field - something like this should do it:
//set record producer created incident's configuration item field to your Asset drop-down variable
current.cmdb_ci = producer.asset_variable_name.ci.toString();
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2022 11:29 AM
Hi Alex,
Use the following script in the script field of record producer;
var gr = new GlideRecord('alm_asset');
if(gr.get(producer.what_do_you_have_an_issue_with)) //I am assuming that 'producer.what_do_you_have_an_issue_with' will return sys_id of record in alm_asset.
current.cmdb_ci = gr.getValue('ci'); // Populating cmdb_ci field of the incident table with ci field of alm_asset table.
Hopefully this will work for you as it is working on my PDI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 02:21 AM
Hi Muhammad,
yes this worked perfectly. Thank you so much 🙂
Alex

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 03:17 PM
There no need to make the GlideRecord call in your script, since the variable itself is a reference to the alm_asset record you can accomplish the same with one line of code and dot-walking -- see my first answer above:
//set record producer created incident's configuration item field to your Asset drop-down variable
current.cmdb_ci = producer.asset_variable_name.ci.toString();
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry