Summary
This script is written to calculate a total contract value based on several responses provided by the user. In this case, we have an original value that is always provided and that is added to any additional change values that are given. If any of the values are left blank, the value is assumed to be zero and the calculation completes as expected.
We have made each question a target for this calculation so that it recalculates no matter which answer option is modified. We also use the round command to round the summation to 2 decimal points. Finally we take the summation of all the values and store that in the question “contractValue” using the assign command.
Script
<script scriptId="tcv"> <body> <s:assign> <s:question path=".contractValueTotal"/> <s:round decimals="2"> <s:add> <s:numberPath path=".contractValue:value"/> <s:numberPath path=".corValue1:value"/> <s:numberPath path=".corValue2:value"/> <s:numberPath path=".corValue3:value"/> <s:numberPath path=".corValue4:value"/> <s:numberPath path=".corValue5:value"/> </s:add> </s:round> </s:assign> </body> <target typeId="contractValue" when="preprocess" shouldReconcile='true'/> <target typeId="corValue1" when="preprocess" shouldReconcile='true'/> <target typeId="corValue2" when="preprocess" shouldReconcile='true'/> <target typeId="corValue3" when="preprocess" shouldReconcile='true'/> <target typeId="corValue4" when="preprocess" shouldReconcile='true'/> <target typeId="corValue5" when="preprocess" shouldReconcile='true'/> </script>
Need more help?
Please visit the Fountayn Contact Information page.