How to hide fields only when list field value is exactly a option

Hareesha
Tera Contributor

I have a requirement where i am having a List type field with Values A,B,C. I have to hide Date field when the list field is only B. When it is accompanied with A or C we should not hide date field. Can anyone help me on this.

6 REPLIES 6

OlaN
Giga Sage
Giga Sage

Hi,

Please provide more information/details on your issue.

What have you tried so far? What debugging have you tried?

Screen shots and such will also help in understanding your issue.

Ankur Bawiskar
Tera Patron
Tera Patron

@Hareesha 

should be an easy task.

what script you wrote? what debugging have you done so far if it didn't work fine?

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

I have tried with UI policy, but while giving the condition its showing CONTAINS . Bu what i need is IS.

@Hareesha 

UI policy won't work

you need to use onChange client script

something like this

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

	var arr = newValue.toString().split(',');
	if(newValue == 'sysIdB' && arr.length == 1){
		// hide the field
	}
	else{
		// show the field
	}

}

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