Read Only fields for a Specific View on a form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 05:53 AM
I have a custom view for a location form. I want to make certain fields read-only. Currently, my code are as follows:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 05:59 AM - edited 01-16-2024 06:01 AM
I would advise using a UI Policy for such a requirements it's just easier to do and best practice IMO. But staying with your Client Script on tip is to make sure you have the 'View' field on your Client Script form set to groups_view. That way it will fire when the view is set to groups_view, there no need to code it.
Without doing any of the above though this will also work. Your code should be:
function onLoad() {
var view = getView(); //get viewname
if (view == 'groups_view'){
g_form.setReadOnly('short_description', true);
}
}
Regards
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 06:00 AM - edited 01-16-2024 06:01 AM
Hello @User393503 ,
there is a small correction in your code. try
var view = getView();
1. Also please check the UI type of your client script it should ALL. and the client script is triggering when the form is loading. (try putting some alerts in your code)
2.Also make sure you are using the correct View name.
3.If you the above mentioned points are correct then check if there any UI policies that are conflicting with your client script?
Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.
Regards,
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 06:02 AM
You can just add the view here on the client script instead of looking for it
Uncheck the Global flag and view will show up. Add the view name there and then this client script will run only for that view. Same thing works on a ui policy as well.