- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2025 07:11 AM - edited 06-22-2025 07:12 AM
Hi,
I have created a display business rule and an onLoad client script. It is not working, and the groups are not loading onto the field User Groups (u_user_groups).
Display Business Rule
(function executeRule(current, previous /*null when async*/ ) {
var aq = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', gs.getUserID());
gr.query();
while (gr.next()) {
aq.push(gr.getValue('group'));
}
g_scratchpad.sreevani = aq;
})(current, previous);
onLoad Client Script
function onLoad() {
var Suman = g_scratchpad.cloeh;
if(g_form.isNewRecord()){
g_form.setValue('u_detailed_description', Suman);
}
}
But when I put in List variable, it is not working.
function onLoad() {
var Suman = g_scratchpad.cloeh;
if(g_form.isNewRecord()){
g_form.setValue('u_groups', Suman);
}
}
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2025 07:22 AM - edited 06-22-2025 07:22 AM
Your scratchpad variable is storing the group record sys_ids,
But, in the dictionary entry pic, I can see that the reference table is "Employee Stay Request" table.
Please check that..
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2025 07:22 AM - edited 06-22-2025 07:22 AM
Your scratchpad variable is storing the group record sys_ids,
But, in the dictionary entry pic, I can see that the reference table is "Employee Stay Request" table.
Please check that..
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2025 07:29 AM - edited 06-22-2025 11:22 PM
Hi @J Siva,
Thank you so much. It worked. I am stupid, instead of pointing to the groups table, I pointed out to the table i am working on.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2025 07:45 AM - edited 06-22-2025 07:46 AM
Sys ID is a unique value across the instance. In your scratchpad variable, you're storing the Sys IDs of group records from the Group table. However, you're attempting to assign these IDs to a field that references the 'Employee Stay Request' table. That's why it didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2025 11:36 PM
@ServiceNow Use6 Glad it helped