How to show popup on catalog item based on the user selection

divyal09
Tera Contributor

If user selects multiple account in a field on catalog form on portal page then a popup should be visible for some of the accounts selected by the user, the account names are random and out of 12 account names 4 account names should show the popup like please contact service desk for assistance

1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage
Tera Sage

Hi @divyal09 ,

 

You can try something like this with onChange client script for that field. Kindly use proper backend names of the variable & account names.

 

 

 

var accountName = g_form.getValue('user_account_name')// please update the correct name of the variable where accounts are added.

if(accountName.indexOf('Account1') > -1 || accountName.indexOf('Account2') > -1 || accountName.indexOf('Account3') > -1 || accountName.indexOf('Account4') > -1){

alert('Please Contact certain team');\\ please rewrite ur expected msg inside the alert

}

 

 

  

Thanks,

Danish

 

View solution in original post

6 REPLIES 6

Chaitra Geetha
ServiceNow Employee
ServiceNow Employee

Hi divyal09,

What I understand is you need to display a message 'please contact service desk for assistance' for a few accounts selected on a catalog item.

This need not be a pop up, it can be a simple message getting displayed on the form (try to avoid popups)

Write an onChange client script on accounts variable and check if the newValue is one of those 4 accounts, if yes display a message like this g_form.addInfoMessage('please contact service desk for assistance'); 

 

 

Thanks,

Chaitra

The alert message is only displaying for one account not for all the accounts selected. The alert or message should be shown for multiple accounts

Hi @divyal09 

 

Please send the code snippet of your client script

 

Thanks

Chaitra

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
var ab = ['57527910dbaf3a806e2afcfaae9619cc', '91909cdf1b3bf450b5ca419ead4bcb93', '96a05cdf1b3bf450b5ca419ead4bcb11', '8ba27d10dbaf3a806e2afcfaae961987', '85b27d10dbaf3a806e2afcfaae96190a', '09c27d10dbaf3a806e2afcfaae9619bc', 'e9637550dbaf3a806e2afcfaae9619e5'];
    if (ab.indexOf(newValue) !== -1) {
              g_form.addInfoMessage("Please provide a business reason why you/team need access");
        g_form.setValue('variable_name',oldValue);

 

    }
}