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

How can I make a field in Service Portal as read only?

Student1
Tera Contributor

Hello,

I have the following requirement.

I want to have a field on Service Portal's form, that is read only. It will contain a value but the end user can not change it.

Is this possible?Any ideas?

1 ACCEPTED SOLUTION

Hi,

you can create onload catalog client script and

1) set the UI Type as Mobile/ Service Portal so that this script executes only for portal and not for native

2) Applies to Catalog Item - true

3) Catalog item - Select your catalog item

4) Type - onLoad

5) Applies on Catalog Item view - true

function onLoad(){

g_form.setReadOnly('city', true);

}


find_real_file.png

Regards
Ankur

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

View solution in original post

14 REPLIES 14

Hi,

you can create onload catalog client script and

1) set the UI Type as Mobile/ Service Portal so that this script executes only for portal and not for native

2) Applies to Catalog Item - true

3) Catalog item - Select your catalog item

4) Type - onLoad

5) Applies on Catalog Item view - true

function onLoad(){

g_form.setReadOnly('city', true);

}


find_real_file.png

Regards
Ankur

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

Hi,

Any issue you are facing here?

Regards
Ankur

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

It works!!

Thank you so much. I appreciate it.

Sajilal
Mega Sage

If its a normal form, you can do this by Native UI Policy or Client Scripts. Make sure the Type field is All so that it works on backend(Native platform) as well as Service Portal.

Please Mark as ✅ Correct if this solves your issue and also mark ???? Helpful if it helps resolve your problem.

Thanks,
Saji

Student1
Tera Contributor

find_real_file.png

Here is my form. I want when the City field to be as a read-only field. So, it will contain a value but the user can not change it.