Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Modal tied to UI Action with condition

Annette Kitzmil
Tera Guru

Hi Everyone,

I am not sure if there is a way to do this or not, but we have code that worked fine until we added more declinations reasons that are now tied to a type_of_decline that should only display 4 of them when the type_of_request and type_of_decline is exception or the other 4 when the type_of_request and type_of_decline is correction.  This is a decline UI action.  Is there any way to get the code below to recognize this and if not, what would you recommend please?

 

function onClick(g_form) {
    g_modal.showFields({
        title: "Enter Declination Reason",
        fields: [{
                type: 'reference',
                name: 'declination_reason', //field name on main RDEP table
                label: getMessage('Declination Reason'),


                reference: 'x_mtbr_ebs_rdep_declination_reasons', //Table being referenced
                referringTable: 'x_mtbr_ebs_rdep_retail_deposit_exception_pricing', //Table referenced from
                referringRecordId: g_form.getUniqueValue(), //Sys_Id of the value being called in the ui action form
                value: g_form.getValue('declination_reason'),
                displayValue: g_form.getDisplayValue('declination_reason'),

                mandatory: true

            },
            {
                type: 'textarea',
                name: 'work_notes',
                label: getMessage('Comments'),
                mandatory: false
            }
        ],
 
Thanks
1 REPLY 1

AnirudhKumar
Mega Sage

In a g_modal, the reference type field doesn't come with a query or a filter that we can rely on... (AFAIK).

There maybe one way out of this...

Use a Choice type field instead and have a glideAjax go get the Declination reasons from server and return them to the Choice field as an array of objects ... something like:

choices: [{
                displayValue: 'Duplicate',
                value: 'duplicate'
            },
                {
                    displayValue: 'Canceled',
                    value: 'canceled'
                }
            ]

 

This way your server script can return only the correct 4 records based on your conditions.