- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 03:21 AM
I have a custom field (unallocated budget, type: Currency) on the project form, I need to change the colour of the field to red when the value of unallocated budget is negative. I am trying to do with field style. The style is working when there is nothing in the value field, but no condition is working:
I tried with the value: - javascript: current.getValue(u_unallocated_budget)<=0 and many more scripts like this but it's not working. Can someone explain why! or suggest any other way out to fulfil the requirement.
I even tried with hardcoded value but that's also not working.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 03:58 AM
currency fields are handled in different way as compared to string or integer fields etc
I believe there are some challenges in applying field style on currency field as the value internally is stored in other currency but displayed based on logged in user session.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 03:39 AM
THOUGHT 1
Not sure if you copy/pasted your attempt, but why is the : in there?
Have you tried just javascript: current.u_unallocated_budget < 0? (I suspect they dont' want zeros to count as red)
If you look at the library of examples, I don't see any using getValue.
THOUGHT 2
When displaying negative currencies, SN adopts the accounting standard for formatting... this is what a negative number actually displays as...
Haven't worked on Field Styles in a long time, but I suspect they run client side, so they might be looking for exactly what's in the field, vs what might be in the XML. So maybe look for a "(" character?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 03:58 AM
currency fields are handled in different way as compared to string or integer fields etc
I believe there are some challenges in applying field style on currency field as the value internally is stored in other currency but displayed based on logged in user session.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 05:19 AM
Thanks for your response,
Is there any other way out to fulfil the requirement then or what's the way forward? I am trying client scripts as well but not reflecting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:16 AM
you can compare using client script and show field message etc
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader