How to add filter to the assignment group field in the modal pop-up?

Vasu20
Tera Contributor

I want the assignment group field in the modal to load only support groups where can i add the filter condition in the code here so that it shows only those.

function onClick(g_form) {

g_modal.showFields({
title: "Please provide all information for incident",
fields: [{
type: 'textarea',
name: 'u_incidentreason',
label: 'Incident description:',
mandatory: true
}, {

type: 'reference', // type of modal (ie text, reference, etc)
name: 'assignment_group', // reference field on the current record used to search
label: 'Assignment Group', // message to display above the search field
mandatory: true, // sets the field to mandatory
reference: 'sys_user_group', // table that the reference field in "name" refers to
referringTable: 'incident', // table of the current record
referringRecordId: g_form.getUniqueValue() // sys_id of the current record

}],
size: 'md'

}).then(function(fieldValues) {

g_form. setValue('u_incidentreason', fieldValues.updatedFields[0].value); 
g_form.setValue("u_incident_creation", 'true'); 
g_form.save();

}

1 ACCEPTED SOLUTION

Glad to help.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

where is this script written?

which modal it opens?

Regards
Ankur

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

This script is written in a ui action of a worskpace button,it opens a g_modal.

Thank you so much.

 

Best Regards,

Vasu

 

Hi,

Did you check any parameter can be passed to set the ref qualifier?

something like this

function onClick(g_form) {

    g_modal.showFields({
        title: "Please provide all information for incident",
        fields: [{
            type: 'textarea',
            name: 'u_incidentreason',
            label: 'Incident description:',
            mandatory: true
        }, {

            type: 'reference', // type of modal (ie text, reference, etc)
            name: 'assignment_group', // reference field on the current record used to search
            label: 'Assignment Group', // message to display above the search field
            mandatory: true, // sets the field to mandatory
            reference: 'sys_user_group', // table that the reference field in "name" refers to
            referringTable: 'incident', // table of the current record
            referringRecordId: g_form.getUniqueValue(), // sys_id of the current record
            sysparm_query: 'sysId1,sysId2'

        }],
        size: 'md'

    }).then(function(fieldValues) {

        g_form.setValue('u_incidentreason', fieldValues.updatedFields[0].value);
        g_form.setValue("u_incident_creation", 'true');
        g_form.save();

    }

Regards
Ankur

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

Tried this approach but did not seem to work.I need those assignment groups to load from the sys_user_group table which has type 'itil' to be loaded.

 

Best Regards,

Vasudev