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.

Business Rule to take string or integer and * and populate total in another field

deneech
Giga Expert

Hello Everyone.

I am trying to create a business Rule to take the number from u_number_of_standard_server_software (right now I have this field as a string, I can change to integer if that will help).

Multiply   it by 6,439

Get the answer and populate it in u_standard_server_software_annual (read-only Currency field)

Here is my code

new num.JPG

Thanks for all your help. I will make sure i mark your advice as helpful or correct if you can help me solve this problem.

Denee

1 ACCEPTED SOLUTION

In your business rule, you can try like this,



var value = parseInt(current.u_number_of_standard_server_software)* 6349;


current.u_standard_server_software_annual_amount = current.u_standard_server_software_annual_amount + ';' + value;



But i believe this can easily be done through onChange() client script on u_number_of_standard_server_software field to get the calculation done, like



var val = (parseInt(newValue) * 6349);


g_form.setValue('u_standard_server_software_annual_amount', val);    



Let's see if this helps.


View solution in original post

10 REPLIES 10

naresh1019
Mega Expert

what is the question here ? what is that you are looking to achieve ?


so my code above is not calculating the u_number_of_standard_server_software * 6349 and it need to populate the answer in this field u_standard_server_software_annual (read-only Currency field).


stink.JPG


In your business rule, you can try like this,



var value = parseInt(current.u_number_of_standard_server_software)* 6349;


current.u_standard_server_software_annual_amount = current.u_standard_server_software_annual_amount + ';' + value;



But i believe this can easily be done through onChange() client script on u_number_of_standard_server_software field to get the calculation done, like



var val = (parseInt(newValue) * 6349);


g_form.setValue('u_standard_server_software_annual_amount', val);    



Let's see if this helps.