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

Hi Denee,



In the beginning of your script, can you please put a gs.log('TEST CALCULATION') and check the logs if it prints normally?



Also, is there any error in the log?



Thanks,


Hello Rafael



It looks like the BR is not running in the logs.



I think its because of the condition. Any thoughts



thanks


Denee


Could you please post a print of your BR's "When to run" tab?


Hello Rafael



new.jpg


Denee,



Instead of "after" (when clause), please select "before". As your script does not have an current.update after its execution it will not update the value. Please let me know if your BR works now.



Thanks,