- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2020 07:20 AM
Hi,
I need to populate a select box variable based on the selections from a reference variable (app_name) and list collector variable (u_database_name1)
I'm using a script include and catalog client script to achieve that functionality. But it's not working. Can you please let me know where to correct the script?
Script Include:
var Getroles = Class.create();
Getroles.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Getbusinessroles: function()
{
var v1 = this.getParameter('sysparm_appid');
var v2 = this.getParameter('sysparm_dbname');
var result = this.newItem("result");
var busrole = new GlideRecord('u_database_role');
busrole.addQuery('u_appid',v1);
busrole.addQuery('u_dbname',v2);
busrole.query();
if(busrole.next()){
return busrole.u_business_role;
}
},
type: 'Getroles'
});
Catalog client script:
Type: Onchange of u_database_name1
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = new GlideAjax('Getroles');
gr.addParam('sysparm_name','Getbusinessroles');
gr.addParam('sysparm_appid', g_form.getDisplayBox('app_name').value);
gr.addParam('sysparm_dbname', g_form.getDisplayValue('u_database_name1'));
gr.getXML(getbusrole);
alert('bus1'+g_form.getDisplayBox('u_database_name1').value);
alert('bus11'+g_form.getDisplayBox('app_name').value);
function getbusrole(response){
//g_form.clearOptions('u_business_roles');
g_form.addOption('u_business_roles','','---None---');
g_form.addOption('u_business_roles','','Role not found');
var result = response.responseXML.documentElement.getAttribute("result");
g_form.addOption('u_business_roles', result);
}
}
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2020 01:44 PM
That's actually good that they are both reference fields on the custom table, so in the client script
gr.addParam('sysparm_appid', g_form.getValue('app_name').toString());
gr.addParam('sysparm_dbname', g_form.getValue('u_database_name1).toString());
The script include depends on what tables are being referenced. Is your app_name variable referencing the same table as your u_appid field? Is your u_database_name1 variable referencing the same table as your u_dbname field? If yes to both, no changes needed to the script include. If either or both table fields are different, let me know how the variable sys_id relates to the field table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2020 07:04 AM
It worked. Thanks Brad.