Field style condition not working for a field on project form

aditirathor
Tera Contributor

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&colon; 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.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@aditirathor 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Uncle Rob
Kilo Patron

THOUGHT 1
Not sure if you copy/pasted your attempt, but why is the &colon; in there?
Have you tried just javascript&colon; 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...

UncleRob_0-1737459169195.png

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?


Ankur Bawiskar
Tera Patron
Tera Patron

@aditirathor 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.

@aditirathor 

you can compare using client script and show field message etc

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader