Can same field which is shown twice be read only in one tab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 09:04 PM
We are showing same field in two different tabs. Can we make one of them read only ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 09:07 PM - edited ‎12-18-2023 09:08 PM
Hi @Prvn1
basically, it is not a good idea to have the same field more than one time on the form. This can lead to issues and unexpected behaviors!
And unfortunately you cannot make one field read-only as this was never foreseen by ServiceNow.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 09:10 PM
Hi please try below code
(function () {
// Specify the tab name where you want the field to be read-only
var readOnlyTab = 'TabName';
var fieldName = 'your_field_name';
var currentTab = g_form.getSectionName(fieldName);
if (currentTab == readOnlyTab) {
g_form.setReadOnly(fieldName, true);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2023 04:01 AM
Hi @Prvn1
Do able but not recommended. And what is the use case of same?
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 05:54 PM
If my answer helps please accept solution