make field read only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 03:02 AM
Hello,
I've created a catalog item and need to set a field to read-only. I attempted to use an onLoad client script with:
However, this approach didn’t work.
The variable in question is a single-line text field and is not linked to a table field.
Do you know how I can achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 03:06 AM
@ammar_k - Please use the "Catalog UI Policy" to make a field Readonly, Mandatory or Visible, instead of client script
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 03:22 AM
Hi @ammar_k
Please use the Catalog UI Policy to make the variable readonly.
PLease mark my answer correct if it helps
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 03:35 AM
Are you sure that variable is not mandatory?
If it is mandatory then you cannot make it readonly
first make it non mandatory and then readonly
g_form.setMandatory('variable_name', false);
g_form.setReadOnly('variable_name', true);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 05:16 AM
Hi @ammar_k ,
Why not utilizing a catalog UI Policy to make it read only?
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/