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

lpruit2
Mega Sage

Greetings @NourT. Apologies for answering your question with a question but what is the business value or purpose of having the UI Action to gain access to the Assignment Group and Assigned To fields? Are those fields not currently accessible on the existing form for some reason? If so, wouldn't it be easier to interact with those fields directly on the form? 

NourT
Tera Contributor

Hello  , thanks for asking.

 

While it is logical to change the assigned group and user from the form, the UI action is needed purely from a user experience and permission-based perspective. there are multiple steps where users have to choose a group with a certain type to assign to, and I need the available users to only be from that list of groups. I hope that answered your question and would appreciate any insight or solutions.

Greetings @NourT. Thank you for the additional information to explain your use-case. Have you looked into a Dictionary Override for the specific target table you are working with? If this table extends the Task table, you could create a Dictionary Override for the Assignment Group and Assigned To fields to have a different Reference Qualifier. I feel this would be less customization in my mind. 

Ankur Bawiskar
Tera Patron

@NourT 

why not directly use form fields?

This is heavy customization.

Are you saying the Assigned to should filter and show only the members from the Group selected?

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