UI Action that allows user to select an assignment group and an assigned _to user in that group

NourT
Tera Contributor

Hello, I have created a UI action workspace form button that when clicked shows a pop-up with the assignment group and assigned to fields. 

 

the first field correctly displays all group options in the sys_user_group table,

however, the "assign to" field is not displaying any users from the sys_user table, let alone those in the group selected above.

 

the pop-up will be used to assign both the group and a member in that selected group, all in the same pop-up, any solutions/suggestions are appreciated.

 

NourT_0-1776065481145.png

 

here is the workspace client script fyr:

 

var fields = [{
        type: 'reference',
        name: 'assignment_group',
        label: 'Assignment Group',
        reference: 'sys_user_group',
        mandatory: true,
       // this line was for testing purposes query: 'sys_id = e92db6cca8100f1c60f7a51d53ae009c',
 
        referringTable: g_form.getTableName(),
        referringRecordId: g_form.getUniqueValue(),
 
    },
{
        type: 'reference',
        name: 'assigned_to',
        label: 'Assign to',
        reference: 'sys_user',
        mandatory: true,
 
        referringTable: g_form.getTableName(),
        referringRecordId: g_form.getUniqueValue(),
 
    },
 
];
 
g_modal.showFields({
    title: "Select a user",
    fields: fields,
    size: 'lg'
}).then(function(fieldValues) {
    g_form.setValue('assignment_group', fieldValues.updatedFields[0].value);
    g_form.setValue('assigned_to', fieldValues.updatedFields[1].value);
    g_form.save();
});
9 REPLIES 9

Yes exactly, the assigned to should only show users from the group selected in the field before it. can this be done?

Greetings @NourT . This should be out of the box behavior that the Assigned to field will be filtered down based on the value of the Assignment Group field. On the Incident table, the Assigned to Dictionary entry shows that it has a Dependent relationship on the Assignment Group field. This means when you select an Assignment group value, the Assigned to will then be filtered down to only show those group members. 

lpruit2_0-1776178011585.png

 

lpruit2_1-1776178093293.png

 



@NourT 

in modal it's not normal field which would directly support reference qualifier similar to how dictionary field works

I doubt applying reference qualifier on 2nd field based on 1st is possible

Try this workaround using UI page and call that from g_modal.showFrame

Filter a reference field in g modal in Workspace 

Then within UI page how to handle the reference qualifier, see this link where I shared solution years ago

Change ui reference query 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@NourT 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@NourT 

I think this is feasible

check this link, response from @simonezini 

Filter a reference field in g modal in Workspace 

Basically create 1 field and then use GlideAjax and bring the members of that group and on the fly add new field and apply the query

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader