Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Select box empty after submitting the catalog item

redth
Giga Expert

Hi,

I'm populating a select box (database name) based on the application selected in the catalog item using client and script include. After submitting the catalog item, the select box is empty and when I click on it, it shows the option I have selected. Used the similar script for many other catalog items and its working fine. See this issue only for this.

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = new GlideAjax('getDb');
gr.addParam('sysparm_name','getDb1');
gr.addParam('sysparm_appName', g_form.getValue('app_name').toString());
gr.getXML(getdataname);

function getdataname(response){
g_form.clearOptions('u_dbName');
g_form.addOption('u_dbName','','---None---');

var msg = response.responseXML.documentElement.getAttribute("answer").split(',');

if(msg == ''){
alert('xxx');
g_form.clearValue('appName');
g_form.clearValue('appId');
g_form.clearValue('appLead');
}

else{
for(var i=0;i<msg.length;i++)
{
g_form.addOption('u_dbName',msg[i], msg[i]);
}
}
}
}

1 ACCEPTED SOLUTION

redth
Giga Expert

I have set the field 'clear variable name' to true in a UI policy by mistake. Set it to false and its working now. Thanks everyone for the inputs.

View solution in original post

5 REPLIES 5

redth
Giga Expert

I have set the field 'clear variable name' to true in a UI policy by mistake. Set it to false and its working now. Thanks everyone for the inputs.