Show alert for select value in list collector variable.

Radhika11
Tera Contributor

Hello,

We have a software list collector variable on catalog item. If selected value is "Other", I would like a alert message popup. Could someone please help?.  Thank you

 

Radhika11_0-1697089517648.png

 

2 ACCEPTED SOLUTIONS

RaghavSh
Kilo Patron

the list collector works on the sys_id, check the sys_id of your your other record and apply on change client script on your list collector field with below script:

 

 

if(g_form.getValue('list_collector_name').indexOf('sys_id_of_other')>-1)
{
alert('your alert message');
}


Please mark the answer correct/helpful accordingly.

 


Raghav
MVP 2023

View solution in original post

@Radhika11 

here is the sample script

Ensure you replace correct sysId for the record which is named as Other

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading) {
		return;
	}

	if(g_form.getValue('variableName').indexOf('sysId') > -1){
		alert('Your Message Here');
	}

}

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

4 REPLIES 4

RaghavSh
Kilo Patron

the list collector works on the sys_id, check the sys_id of your your other record and apply on change client script on your list collector field with below script:

 

 

if(g_form.getValue('list_collector_name').indexOf('sys_id_of_other')>-1)
{
alert('your alert message');
}


Please mark the answer correct/helpful accordingly.

 


Raghav
MVP 2023

Ankur Bawiskar
Tera Patron
Tera Patron

@Radhika11 

please share what script did you try? it should be an easy one.

are you saying only when 1 value is selected i.e. Other then alert should come?

OR

if Other is selected along with other value then also alert should come?

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

Good morning @Ankur Bawiskar 

I have not tried any script yet because I don't know where to begin. You are correct; the alert should come up only when 'Other' value is selected. Alternatively, if the 'Other' value is selected along with other values, then the alert should come up as well. Please help.

@Radhika11 

here is the sample script

Ensure you replace correct sysId for the record which is named as Other

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading) {
		return;
	}

	if(g_form.getValue('variableName').indexOf('sysId') > -1){
		alert('Your Message Here');
	}

}

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