I don't want to apply styles to read-only fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 12:50 AM
I edited the style of the field and gave it color.
However, I want the color to be gray if it is read-only as a requirement.
Styles now take precedence even if read-only.
Is there a way to reject a style if it is read-only?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 01:35 AM
Hi @bonsai
You may need a client script to identify whether or not a field is Readonly, then set the style of the field accordingly.
Sample below with OnLoad Client Script on 2 different fields Priority and Impact
function onLoad() {
if (g_form.isDisabled('priority') != true) {
var ctrPriority = g_form.getControl('priority');
ctrPriority.style.backgroundColor = 'red';
}
if (g_form.isDisabled('impact') != true) {
var ctrImpact = g_form.getControl('impact');
ctrImpact.style.backgroundColor = 'red';
}
}
Cheers,
Tai Vu 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 03:12 AM
An error occurred when executing "ctrPriority.style.backgroundColor".
Reference and list fields are no longer available. . .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 05:48 PM
I noticed that I got an error because I tried to implement it with a UI policy.
However, this script did not color fields of reference type, list type, or True/False type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 10:48 PM
Hi @bonsai
For the Reference field type, you can try this below.
g_form.getControl('sys_display.<table_name>.<field_name>');
Can you share what kind of style you'd like to set for the List and True/False field types?
Cheers,
Tai Vu