How to create a business rule to calculate multiple (11) currency fields

deneech
Giga Expert

Hello Everyone

I wasn't able to accomplish a business rule to calculate 11 currency fields so I create to subtotals for each column. I was able to get this to work.

Now I am trying to create a BR to calculate the two subtotals and my Condition or Code is not working.   Can someone please?

updated tco.JPG

help.JPG

thanks

Denee

____________________________________________________

I have a form that has 11 currency fields, that I need to get the the total when saved/Updated or submitted.

I am struggling with the condition. My current Business Rule

tco.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

Message was edited by: Denee Harris

1 ACCEPTED SOLUTION

Your script looks okay to me - are these all configured to run "before"? You could have an ordering problem where "Calculate Total TCO" is running before those other fields are themselves calculated.



There's an easy way to trace this down if you add some debug statements to your business rules. You should use gs.debug("Debug message here") in all 3 business rules to print the field values and the calculation result. Adding the debug logs makes it very easy to see what the business rule has actually done when you are debugging.



Add some debug statements to all of these business rules and enable the debug logging and business rule debugging tools via System Diagnostics > Session Debug > Debug Log, and System Diagnostics > Session Debug > Debug Business Rule.



After you do this, change some values on your form, save it, and look at the output at the bottom of the page. The debugging logs will stand out with [DEBUG]. You need to read these logs and see how these rules are flowing, and verify the order they are running in.


View solution in original post

16 REPLIES 16

Hello Rafael its not calculating, nor is it putting anything in the field. The 3 screenshots are in my original message, I edited it. Please let me know if you would like me to attach them again.



thanks


denee


Can you post the current version since you have made some changes since originally posting?


Hello Patrick



I created Two Subtotal Fields with 2 Business Rules


Field Names


u_subtotal_r


u_subtotal


Business Rules for subtotals


left.JPG


right.JPG


Form Calculates Left and Right Subtotals


working.JPG


Total TCO BR


total.JPG


Your script looks okay to me - are these all configured to run "before"? You could have an ordering problem where "Calculate Total TCO" is running before those other fields are themselves calculated.



There's an easy way to trace this down if you add some debug statements to your business rules. You should use gs.debug("Debug message here") in all 3 business rules to print the field values and the calculation result. Adding the debug logs makes it very easy to see what the business rule has actually done when you are debugging.



Add some debug statements to all of these business rules and enable the debug logging and business rule debugging tools via System Diagnostics > Session Debug > Debug Log, and System Diagnostics > Session Debug > Debug Business Rule.



After you do this, change some values on your form, save it, and look at the output at the bottom of the page. The debugging logs will stand out with [DEBUG]. You need to read these logs and see how these rules are flowing, and verify the order they are running in.


Hello Patrick



Thanks so much, It was the order.



Denee