i want to subtract two integer fields and result should stored in another field

malaisamy1
Kilo Contributor

Hi Guys,

I have a problem that i am not able to subtract two integer fields..

I have used parseInt method also.. its not giving me the correct result.

Please find my onload script. and let me know if anything missing

var a = parseInt(g_form.getValue('si_actual_resolution_duration'));

  var b = parseInt(g_form.getValue('hold_diff'));

  var result = parseInt(a-b);

g_form.setValue('actual_resolution_duration', result);

Please help me to resolve the issue.

Malaisamy J

1 REPLY 1

Deepak Kanavika
Tera Expert

HI Malaisamy,



Your code looks correct, you may need to recheck the names of the integer fields. Following is a script i tried and found working well, have a look


CODE :

try{


            var a = g_form.getIntValue('u_a');


                      alert('1 > '+a);


            var b = g_form.getIntValue ('u_b');


                      alert('2 > '+b);


            var result = a-b;


                      alert("c : "+result);


                    g_form.setValue('u_c', result);


  }catch(e){alert(e);}


You could also use getValue but as yours is an Interger field, we can directly use int getIntValue(fieldName), and save the parsing to Int.



Hope it helps !!



Thanks,


Deepak K


(please mark answered/helpful if you feel so..)