Change background color of read only field

Marcel H_
Tera Guru

I know that this is one of those types of things that aren't a big deal, and honestly I can deal without it, but it's driving me crazy not to be able to do this the way that I expect. I've read a lot of posts here in the community, and on the internet in general, but none of the solutions really seem to work for me for what I'm trying to do. It seems like it should be an easy thing to do, and something that should be easier to configure in the base system, since visual queues draw someone's eye to something that might need attention.

Of course the thing that I'm trying to do is change the background color of a field on a form, which seems to be difficult at best. Setting the style so it displays in the list is simple and straight forward, but forms are apparently much different. I've used a ton of examples from the posts here, and I think the closest that I got was Change form color on state change

function onChange(control, oldValue, newValue, isLoading) {

var elementID = gel("incident.priority");

switch(newValue) {

case "1": elementID.style.backgroundColor = "red"; break;

case "2": elementID.style.backgroundColor = "tomato"; break;

case "3": elementID.style.backgroundColor = "orange"; break;

case "4": elementID.style.backgroundColor = "yellow"; break;

case "5": elementID.style.backgroundColor = "green"; break;

default: elementID.style.backgroundColor = "white"; break; } }

The above script from that article works just fine on the Incident table, but modifying the script for my custom table, I'm getting nowhere. I've tried a ton of different scripts, in various configurations/modifications and used Client Scripts (onChange, onLoad), UI Policy scripts, and scripts in the variable field of a field style record. My custom table is extended from ast_leases (which itself is extended from the ast_contracts table) and I'm trying to change the background color of the Expiration Level field (expiration) on the form.

Part of the reason that I would like the background color changed, is that the field is also being pulled into another table's form as part of a reference, and the users are more likely to see if there than in the list of records for the originating table.

Part of what is really driving me crazy though is that I can see other places in the system where fields on forms are colored, so it seems like it should be able to be done without all of the trouble that I've been having:

find_real_file.png

5 REPLIES 5

Tim Grindlay
Kilo Sage

For anyone trawling through the community looking for help on field styles not applying to forms, we had a similar issue with the 'Conflict status' field on the change form. I found KB0564026 on the Hi portal that states: "Our product documentation states that field styles based on Value only work on lists and that to apply field styles on both the field and the form, users should leave the Value field blank. "

If I remove the value in the value field on the field style, the field style will apply, however this no longer works as intended. The article also states: "However, value-based styles are still applied sometimes, such as on a popup or for some fields." which is true.

And finally: "After carefully considering the severity and frequency of the issue, as well as the the cost and risk of attempting a fix, a decision has been made not to address this issue in any current or future releases." We are on Madrid.