How to hide choice field on incident form? for example: If I have added phone as an choice on incident form and I don't want the users to view that phone choice what to do?

bhavya kommare1
Tera Contributor

How to hide choice field on incident form? for example: If I have added phone as an choice on incident form and I don't want the users to view that phone choice what to do?

4 REPLIES 4

Musab Rasheed
Tera Sage
Tera Sage

Hello,

If you want to hide Phone for everyone , either you can make that choice and inactive true or you can remove from choice list by going to 'Configure choices' for that field.

Please hit like and mark my response as correct if that helps

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

I don't want to make it inactive. I just want to hide it on incident form.

 

@bhavya kommareddy , Write onload client script like below and choice will be available only for Admin, you can tweak accordingly

function onLoad() {
   //Type appropriate comment here, and begin script below
	if(!g_user.hasRoleExactly('admin'))
		{
	g_form.removeOption('contact_type', 'phone');
		}
   
}

Also, if you want to hide it for all then simply go to 'Configure choices' and remove accordingly simple ?

find_real_file.png

find_real_file.png

Please hit like and mark my response as correct if that helps

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Naga Ravindra R
Kilo Sage

Hello Bhavya,

You can use the following method:

GlideForm - removeOption(String fieldName, String choiceValue)

g_form.removeOption('choice name', choice value);

Please also check here if you have any questions:

https://docs.servicenow.com/bundle/tokyo-application-development/page/app-store/dev_portal/API_reference/GlideForm/concept/c_GlideFormAPI.html#r_GlideFormRemoveOption_String_String

Please mark as correct/helpful if it helps 🙂

Also, Please be more specific from next time when you are asking a community question.

How to hide choice field on incident form? for example: If I have added phone as an choice on incident form and I don't want the users to view that phone choice what to do?

At one stage, you mentioned to hide choice field after you added to hide phone as a choice. It's confusing.

Thanks!