The CreatorCon Call for Content is officially open! Get started here.

list collector to show display message

ServiceNow Use6
Tera Guru

Hi,

I have a list collector variable, and I have to display a message every time, we select a value. For one value selection, it is displaying the message not displaying if I select more than one message. Kindly help.

 

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


var new_Variable = g_form.getDisplayValue('application');

if(new_Variable == 'Chexar'){
	
	g_form.showFieldMsg('application',"Used to assist customers with questions involving ATM Check Cashing.", 'info', false);
}
	else if (new_Variable == 'IVFR'){
		g_form.showFieldMsg("application", "Grants override access to IVFR for Contact Center associates only.", "info", false);
	}
		else if (new_Variable == 'TransPerfect'){
		g_form.showFieldMsg("application", "Provide Interpreters to assist Contact Center agents.", "info", false);
	}
	else if (new_Variable == 'SpeedPay'){
		g_form.showFieldMsg("application", "Used to make payment from another financial institution.", "info", false);
	}
	else if (new_Variable == 'VerID'){
		g_form.showFieldMsg("application", "Program that provide questions to be ask of customer to help verify identity.", "info", false);
	}
	
}

 

onChange.PNG

 

Regards

Suman P.

7 REPLIES 7

Mohith Devatte
Tera Sage
Tera Sage

Hello @ServiceNow Use6 ,

If multiple values are selected then list collector will return values in comma separated format.

so you need to loop in all the values like below 

 

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


var new_Variable = g_form.getDisplayValue('application').split(',');

for(var i=0; i<new_Variable.length; i++)
{
if(new_Variable[i] == 'Chexar'){
	
	g_form.showFieldMsg('application',"Used to assist customers with questions involving ATM Check Cashing.", 'info', false);
return;
}
	else if (new_Variable[i] == 'IVFR'){
		g_form.showFieldMsg("application", "Grants override access to IVFR for Contact Center associates only.", "info", false);
return ;
	}
		else if (new_Variable[i] == 'TransPerfect'){
		g_form.showFieldMsg("application", "Provide Interpreters to assist Contact Center agents.", "info", false);
return ;
	}
	else if (new_Variable[i] == 'SpeedPay'){
		g_form.showFieldMsg("application", "Used to make payment from another financial institution.", "info", false);
return;
	}
	else if (new_Variable[i] == 'VerID'){
		g_form.showFieldMsg("application", "Program that provide questions to be ask of customer to help verify identity.", "info", false);
return;
	}
    }
}

 

 

Hope this helps 

Mark the answer correct if this helps you 

Thanks

Hi @Mohith Devatte ,

When I do this, the first message stays the same all the time, even though I select a couple of other values. How can I make it better?

 

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


    var new_Variable = g_form.getDisplayValue('application').split(',');

    for (var i = 0; i < new_Variable.length; i++) {
        if (new_Variable[i] == 'Chexar') {

            g_form.showFieldMsg('application', "Used to assist customers with questions involving ATM Check Cashing.", 'info', false);
        }
        if (new_Variable[i] == 'IVFR') {
            g_form.showFieldMsg("application", "Grants override access to IVFR for Contact Center associates only.", "info", false);
        }
        if (new_Variable[i] == 'TransPerfect') {
            g_form.showFieldMsg("application", "Provide Interpreters to assist Contact Center agents.", "info", false);
        }
        if (new_Variable[i] == 'SpeedPay') {
            g_form.showFieldMsg("application", "Used to make payment from another financial institution.", "info", false);
        }
        if (new_Variable[i] == 'VerID') {
            g_form.showFieldMsg("application", "Program that provide questions to be ask of customer to help verify identity.", "info", false);
        }
    }
}

 

onChange.PNG

 

Regards

Suman P.

@ServiceNow Use6 i think its because of field message method where it might be a case where only one field message is shown.

Please try to use addInfomessage where it can accept multiple infos if it goes to multiple loops 

It didn't help me @Mohith Devatte . Thank you for your help.

Regards

Suman P.