Select Box type variable and its fields are not working properly.

Amol Pawar
Tera Guru

Hi All,

I have created a record producer. My first variable is a 'Select Box' type of variable in which I have added 4 choices. Based on each choice value selection, I have some variables (fields) to populate, and they are populating correctly. But only if I select each choice in a top-to-bottom manner. If I select the last-choice value first and then if I select the first-choice value, then fields are not populating correctly. Sometimes only a few fields are populating.

AmolPawar_0-1704775751321.png

AmolPawar_1-1704775776278.png

I have many common variables in all 4 choices, so I have created UI policies to populate only desired variables. Some variables are called in all the UI policies, is it the cause? I have called all the variables in UI actions, should I use the script section to avoid such a mismatch?

Let me know if anyone knows the workaround for this.

 

Thanks in advance,

Amol

 

 

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Amol Pawar 

you should have only 1 onChange catalog client script on that select box and don't keep multiple UI policies as it might conflict because of order

Within that script first clear all the variables then check what's the new value and based on that auto-populate only desired variables

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

	// clear all variables

	if (newValue == "choice 1") {
		// set your desired variable here
	} else if(newValue == 'choice 2'){
		// set your desired variable 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