- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2023 11:04 PM
Hi,
I have the List collector variable called 'u_ramad' that is a reference to the sys_user table. I have the field 'u_ramad' of type List (reference to sys_user table as well) in my 'u_ou' table.
I need to write onLoad client script that called a script include which return the values from the list field 'u_ramad' from the u_ou table. These values should be populated automatically in the right bucket of the 'u_ramad' list collector variable.
function onLoad() {
var user = g_form.getvalue('requested_for');
var ga = new GlideAjax('fill Ramad');
ga.addParam( sysparm_name, isRamad);
ga.addParam('sysparm_std', user);
ga.getXML(getResponse);
function getResponse(response) {
var ans = response.responseXML.documentElement.getAttribute("answer');
alert(ans);
if(ans != '') {
g_form.setvalue('u_ramad', ans);
}
}
Script include:
var fillRamad = Class.create();
fillRamad.prototype object.extendsObject(AbstractAjaxProcessor, {
isRamad: function() {
var us = this.getParameter('sysparm_std');
var gr= new GlideRecord('sys_user);
gr.addEncodedQuery('sys_id='+us.toString());
gr.query();
if(gr.next()) {
var hi = gr.u_hierarchy.toString();
hi = hi.split('/')[0];
var sp= new GlideRecord('u_ou');
sp.addEncodedQuery('u_ou=' + hi);
sp.query();
if(sp.next()) {
return sp.u_ramad.toString();
}
},
type: 'fillRamad'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 12:17 AM
Hi @Alon Grod
can you try to update Variable attribute to "glide_list"
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2023 11:30 PM
since you want this to happen on form load, why not use default value for that variable?
I assume requested_for must be populated with logged in user? If yes then you can use default value
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2023 11:33 PM
@Ankur Bawiskar how can I achieve that using default value? the default value should be the list field 'u_ramad' from u_ou table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2023 11:34 PM
@Ankur Bawiskar the default value should be dynamic according to the requested for users but it should also be on change (if the user changes the requested for after on Load)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 01:23 AM
why to use attribute glide_list?
It will only show as glide list in native but on portal side it will be normal list collector
check my blog on how to auto populate list collector based on another variable
Dynamically set list collector on change of variable
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