Service Catalog - Lookup Select Box - Script Include - Catalog Clent Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 08:30 AM
Asking for some help please.
Want to take the selected item from the Lookup Select Box to populate the Request with information from the cmdb_ci_computer table. - I am either getting nothing or getting undefined as returned value.
Catalog Client Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 08:56 AM
Hi @Mark Lanning Have you tried to add log in script include to check if client side data going into script include ?
Also sysparm_name parameter reserved for function name, so please change it to different name , eg: sysparm_id
eg:
var gajax = new GlideAjax('demoDetailsUtil');
gajax.addParam('sysparm_name', 'getModalityDetails');
gajax.addParam('sysparm_id', newValue);
gajax.getXML(setModalityDetails);
Please try and let me know if it does not work, also add logs.
Thanks,
Harsh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 12:10 PM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var demo = g_form.getValue('select_the_available_demo_configuration'); // variable value
g_form.setValue('modality_ae_title', demo.u_modality_ae_title);
g_form.setValue('modality_station_name', demo.u_modality_station_name);
g_form.setValue('modality_port', demo.u_modality_port);
g_form.setValue('network_wired_ip_address', demo.ip_address);
g_form.setValue('network_wired_mac_address', demo.mac_address);
This will return undefined. Adding logs to the previous attempt with script include and client script did not register.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 01:06 PM - edited 04-12-2024 01:10 PM
Hi @Mark Lanning,
Had a quick look at the script and the obvious ones that I can see are the following:
Change the param name in the Client script:
gajax.addParam('sysparm_name', 'getModalityDetails');
gajax.addParam('sysparm_name', newValue);
You would need to change the second param to something other than sysparm_name. Also, make sure you update the Scrtip Include with the new param name as well.
Are you sure the CI query is correct?
Cheers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 12:35 PM
Sorry, still not getting this, is it because I am using a Lookup Select Box?
Script Include
var getDemoinfo = Class.create();
getDemoinfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
get_demo: function() {
var demo = this.getParameter('select_the_available_demo_configuration');
var gr = new GlideRecord("cmdb_ci_computer");
gr.addQuery("sys_id", demo);
gr.query();
if (gr.next()) {
return;
}
},
type: 'getDemoinfo'
});
Catalog Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var gaDemo = new GlideAjax('getDemoinfo');
gaDemo.addParam('sysparm_name', 'get_demo');
gaDemo.addParam('sysparm_fields', '["u_modality_ae_title","u_modality_station_name","u_modality_port","ip_address","mac_address","u_modality_subnet_mask","u_modality_gateway,"u_wireless_ip","u_wireless_mac_address","u_wireless_subnet_mask","u_wireless_gateway","u_modality_user","u_modality_password","u_ssid","u_security_mode","u_wpa_mode","u_authentication_type","u_one_logical_name","u_one_ae_title","u_one_ip_address","u_one_port","u_two_logical_name","u_two_ae_title","u_two_ip_address","u_two_port","u_three_logical_name","u_three_ae_title","u_three_ip_address","u_three_port","u_four_logical_name","u_four_ae_title","u_four_ip_address","u_four_port"]');
gaDemo.getXML(_handleResponse);
function _handleResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//var demo = g_form.getValue('select_the_available_demo_configuration'); // variable value
g_form.setValue('modality_ae_title', answer.u_modality_ae_title);
g_form.setValue('modality_station_name', answer.u_modality_station_name);
g_form.setValue('modality_port', answer.u_modality_port);
g_form.setValue('network_wired_ip_address', answer.ip_address);