- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 05:15 AM
Hi,
I am autopopulating multiple variables of which one SelectBox is not autopopulating. Kindly help.
GlideAJAX
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == "") {
g_form.setValue('current_primary_approver', "");
g_form.setValue('share_type', "");
g_form.setValue('protocol_type', "");
} else {
var ga = new GlideAjax('populate_modify_network');
ga.addParam('sysparm_name', 'get_modify');
ga.addParam('sysparm_share_path', newValue);
ga.getXML(callBackFunction);
function callBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var op = JSON.parse(answer);
g_form.setValue('current_primary_approver', op.approver);
g_form.setValue('share_type', op.type);
g_form.setValue('protocol_type', op.protocol);
}
}
}
ScriptIncludes
var populate_modify_network = Class.create();
populate_modify_network.prototype = Object.extendsObject(AbstractAjaxProcessor, {
get_modify : function()
{
var path = this.getParameter('sysparm_share_path');
var values = {};
var gr = new GlideRecord('u_cmdb_ci_file_share');
gr.addQuery('sys_id',path);
gr.query();
if(gr.next())
{
values.approver = gr.managed_by.toString();
values.type = gr.u_type.getDisplayValue();
values.protocol = gr.u_protocol.getDisplayValue();
}
return JSON.stringify(values);
},
type: 'populate_modify_network'
});
You can see Share Type populating but not Protocol Type. Both are SelectBox variables.
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 05:23 AM
what came in the JSON? is the JSON coming fine?
I could see the variable is drop down type. I hope the choices for that drop down variable and the choices for field u_protocol are same.
If yes then update this line so that you get choice value and not choice label
values.protocol = gr.u_protocol.toString();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 05:23 AM
what came in the JSON? is the JSON coming fine?
I could see the variable is drop down type. I hope the choices for that drop down variable and the choices for field u_protocol are same.
If yes then update this line so that you get choice value and not choice label
values.protocol = gr.u_protocol.toString();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 05:25 AM
ideally no scripting required if you use auto populate feature
It basically means you are making other 2 variables dependent on your reference variable
Auto-populate a variable based on a reference type variable (Utah)
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader