Need Clarification

Abdul
Tera Contributor

Hi 

 

I have a scenario where in we have a MRVS which includes countries from core_country table.

The ask is that whenever a user selects one of the 20 blocked countries, the user should be given a popup saying that "this is a excluded country"

Now i have done that, but i have done via ui policy.

So when i select one country the pop up works. But when i select another country right at the same time the pop up isnt working 

May i know why and can we avoid it by ui policy itself?

 

Thanks 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Abdul 

Ensure Reverse if false is selected and if condition doesn't match then you reverse showing that message

Another way

you can use onChange catalog client script which applies on MRVS and select that Country variable

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var arr = ['blockedCountry1', 'blockedCountry2', 'blockedCountry3']; // give here those 20 countries
    g_form.hideFieldMsg('variableName'); // give here variable name

    if (arr.indexOf(newValue) > -1) {
        var message = 'You cannot select this country';
        g_form.clearValue('variableName'); // give here user_id variable name
        g_form.showFieldMsg('variableName', message, 'error', true);
    }
    //Type appropriate comment here, and begin script below

}

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

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Abdul 

Ensure Reverse if false is selected and if condition doesn't match then you reverse showing that message

Another way

you can use onChange catalog client script which applies on MRVS and select that Country variable

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var arr = ['blockedCountry1', 'blockedCountry2', 'blockedCountry3']; // give here those 20 countries
    g_form.hideFieldMsg('variableName'); // give here variable name

    if (arr.indexOf(newValue) > -1) {
        var message = 'You cannot select this country';
        g_form.clearValue('variableName'); // give here user_id variable name
        g_form.showFieldMsg('variableName', message, 'error', true);
    }
    //Type appropriate comment here, and begin script below

}

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

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