Make fields read only for certain views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2022 04:40 PM
Hi everyone!
I'm new to ServiceNow, and I am in the process of building an app to practice some newly acquired skills. In my app, I created two different form views, outside of the default view. I'm wanting to make a certain field read only for the default view and one of the others views, but when I go to UI Policies and uncheck the Global option, it only lists one view to apply the change to. So I figured that I would have to actually script what I'm trying to do, but unsure how to go about it since the scripting examples I've seen consist of only mentioning the field name and data type and not the view that it would apply to. I've tried finding answers on here and Google but no luck yet.
In short, I want to make a field read-only in more than one view, but not have it apply to all the views. Is there a way to do that? And if so, how?
Thank you for your help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2022 06:11 PM
HI the below will give you view names in client script. You can have onload client script
var view = getView(); //get viewname
if (view == 'self_service'){
g_form.setReadOnly('fieldname',true);
}
Harish