Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Page dynamically calculated fields

yundlu316
Kilo Guru

I've created a form using a UI Page and would like some of the fields to dynamically change depending on what is entered in other fields.   For example if a user fills out field A with $100,000 and field B with $25,000, is it possible for field C to dynamically change to $125,000 (A+B) without submitting or reloading the page?   Would that be a client or processing script?

Thanks!

1 ACCEPTED SOLUTION

You do not need onChange client script declaration. Remove everything from the client script section and just copy this


function sum(){


  $('H').value=parseFloat($('D').value)+parseFloat($('G').value);


}


View solution in original post

28 REPLIES 28

Abhinay Erra
Giga Sage

Change the deduct_3() function to this



function deduct_3(){


  var c = parseFloat($('deductions_adjustments_1').value) - parseFloat($('deductions_adjustments_2').value);


  if (c<= 0) {


  $('deductions_adjustments_3').value = 0;


  }


  else {


  $('deductions_adjustments_3').value =c;


  }


  }


I actually tried that first, but ServiceNow doesn't like that <= character


Abhinay Erra
Giga Sage

That is weird. Are you using this in client script section?


Nope, doing it in the HTML space like sum()



find_real_file.png


Abhinay Erra
Giga Sage

Use them in the client script section