
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 02:07 AM
I Create a Style for my STATE field.
I am trying to change the color for a certain state value so As per this PD I created the following
- Field: State
- Value: javascript: current.u_state == "Draft"
- Style: background-color:red; color:white;
(My State field is called u_state)
But it does not work, I also tried to change the value to the following (which is the value in u_state field for [Draft] state)
- javascript: current.u_state == "1"
- javascript: current.u_state == 1
It doe not work.
To see if the style actually works, if I leave the [Value] field empty my state field changes color but I want it to change color when the state is in Draft.
What am I doing wrong?
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 02:21 AM
Hi,
field styles with value will work only on list.
Are you sure you are comparing correct choice value for Draft
Field styles on list are evaluated only once and they show the style based on database value of that field
If you change the state value and save and then refresh the list it would show the newer style matching the respective condition
This should work fine provided Draft is having choice value as 1
javascript: current.u_state.toString() == '1'
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 02:21 AM
Hi,
field styles with value will work only on list.
Are you sure you are comparing correct choice value for Draft
Field styles on list are evaluated only once and they show the style based on database value of that field
If you change the state value and save and then refresh the list it would show the newer style matching the respective condition
This should work fine provided Draft is having choice value as 1
javascript: current.u_state.toString() == '1'
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 06:39 PM
Thanks