getElement() not working

Tapish Sharma1
Kilo Sage

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 

1 ACCEPTED SOLUTION

@Tapish Sharma Seems like getControl(), getElement(). getDisplayBox() won't work with Currency field.

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?

View solution in original post

9 REPLIES 9

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Tapish,

Try using g_form.getControl('u_hard_savings')

Hi Hitoshi , 

i am trying to add the bg color , but that is not working 

That what I thought.

Client Script

function onLoad() {
    var element = g_form.getControl('u_hard_savings');
    element.style.backgroundColor = 'red';
}

Execution result. Background color of field u_hard_savings becomes red.

find_real_file.png

The problem maybe with the if statement. Following is comparing value of u_hard_savings field to be less than 0. For this to be true, field u_hard_saving must return an integer. What is the type of u_hard_saving?

g_form.getValue('u_hard_savings')<0