Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Style background-color won't apply on list when field is empty

staceyrocheleau
Kilo Guru

I've created some style entries for a field. One is set to true based on a condition of another field and these styles get applied correctly on the form view.

On the list view, if the field is empty, the style is not applied.If I view the form, it is applied.

Field: blank

Style not applied in list view (background-color)

Style applied in form view

Field: value

Style applied in list view

Style applied in form view

I really want these fields to appear greyed out on the list view. Just a side note that they are also restricted by an ACL for write access but only show as greyed out by the default style (being read only) on the form view.

The issue is that I WANT the field to be blank AND greyed out in the list view when it is read-only.

12 REPLIES 12

it works if you can create two field styles, one with the value is blank and one with javascript: true;find_real_file.png


find_real_file.png


But I actually need to check another field to know if I want to highlight it grey. I need to see if that field should be blank. Having a value = blank won't work in this case because it should be highlighted based on my condition (i.e. javascript: <my condition that is true> --> highlight, javascript: <my condition is false> --> don't highlight) 😕



And this condition is true for the fields regardless of their value (if they are blank or have a value, the condition will be true) so it should change the color. But it doesn't because the blank values (even with the condition true) are not highlighted...



To clarify.



Record 1:


Sunday should be read-only (ACL results to this) and greyed out with no value


Monday should allow write and not be greyed out but also has no value until someone enters something



Record 2:


Sunday should allow write and not be greyed out but also has no value until someone enters something


Monday should allow write and not be greyed out but also has no value until someone enters something



So for Record 1 --> I'd want Sunday to be greyed out in the list but not Monday or any of the fields in Record 2.



If I put a style with value = blank, it would apply to all of these fields which I don't want.



Instead I'm running a check to see if those fields should be written to and trying to grey out the ones that should be read only. Right now the only way the user finds out they can't write to them in the list is by double clicking and finding out security doesn't allow them to.


If Field A is blank you want to highlight Field B?


No. And I'm using the same condition on the ACL as I am in the style code.



Field A <-- looking at this for condition


Field B <-- field I want to highlight if condition from Field A is true. I want to highlight it based on this condition not on whether it's blank or has a certain value.



Does that make sense? Basically it DOES work on the form but when in the list view, it only highlights if there is something in the field.


Hi Stacey,




I'm experiencing the same issue, were you able to find a solution for this?



Thank you