Business rule to display decimal value

snowuser111
Kilo Guru

Hi,

I want a field F1 in Incident table which will store the value (F2 * F3) where F3 can be decimal upto two decimals like 356.87.

What type F1 , F2 and F3 should be while creating is it String ?

Need business rule to store this value.

Can anyone suggest please

Thanks

1 ACCEPTED SOLUTION

function onSubmit()


{


      var a = g_form.getValue('u_people_number'); //this field should contain whole numbers - decimal


      var b = g_form.getValue('u_hours_on_swat');   // this field should contain decimal upto 3 digits.-decimal


      var c = (a*b);


      g_form.setValue('u_total_hours', c);   // this field should store value of (a*b) -decimal


          return true;


}


View solution in original post

7 REPLIES 7

snowuser111
Kilo Guru

i tried client script as below for Incident table. But the field does not display the value. I cant see the result.Can anyone help why it does not show?


---------------------------------------------------------------------


function onSubmit()


{


      var a = 356;


      var b = 456.45 ;


      var c = (356*456.45);


      g_form.setValue('u_swat_hours', c);


         


}


---------------------------------------------------------------------


You mentioned it as business rule in the subject bat it looks like a client script from the code. If its a business rule then you cannot   use g_form in there ,   use current instead .   also change name of the function to onBefore() or onAfter() depending upon the type of BR .  


If you are using a client script then try to alert variable c .


Actually i was first trying from BR then went for Client script. I was testing the code below. But not sure if all fields should be decimal or string.



__________________________


function onSubmit()


{


      var a = g_form.getValue('u_people_number'); //this field should contain whole numbers


      var b = g_form.getValue('u_hours_on_swat');   // this field should contain decimal upto 3 digits.


      var c = (a*b);


      g_form.setValue('u_total_hours', c);   // this field should store value of (a*b)


          return true;


}


_________________________


The Code seems to be correct . the only issue may be with type of the variable . as Kalaiarasan P mentioned use decimal and it should work.