- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 11:28 PM
Hi Everyone,
I am trying the below client script but it is not working. The field type is currency-
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('u_hard_savings')<0){
var element = g_form.getElement('u_hard_savings');
element.style.backgroundColor='red';
}
}
Any hints would be helpful, thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 12:32 AM
Tried with Field Style but condition in Value field only works on a list and not on the form. It's either always red or none.
Is this for ServicePortal or for UI?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 11:44 PM
Hi hitoshi,
It doesnt work even if i remove the if condition. As mentioned above my field type is "currency". can you try for that once

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 12:32 AM
Tried with Field Style but condition in Value field only works on a list and not on the form. It's either always red or none.
Is this for ServicePortal or for UI?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 12:40 AM
Hi Hitoshi,
thank you so much , it is for ui form . So I guess it is not possible then

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 12:54 AM
Strongly don't suggest this but it is possible using DOM manipulation. This may not work after versioning up. I've tested the following in San Diego. Replace "<form name>".
if (parseInt(g_form.getValue('u_hard_savings').split(';')[1]) < 0) {
var element = gel('<form name>.u_hard_savings.display');
element.style.backgroundColor = 'red';
}
Execution results:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 12:35 AM
BTW, I've also found that getValue() on currency will prefix with the currency mark so it won't be a number.
e.g.
USD;10.0
So the if condition will be as follows:
if (parseInt(g_form.getValue('u_hard_savings').split(';')[1]) < 0) {