I’m trying to set a variable to sum the line items on an order form. I believe the function SUM should work in a calculation. However, the variable $total in the script below calculates only the total for the current record. The variable $sum calculates correctly, but I’m trying to avoid summary fields. Any suggestions?
Put the lines into a session record. . Master detail for each session. Sum the field via SQL.
Could you tell us the relationship of the form? Is it order form to line item( in a portal ) or something like that?
You may use replace field content to a global field which calculate the total of line total.
Sum works on a set of fields. What it grabs for each field depends on whether the data is in the current table occurrence (TO) or a related TO. For the current TO, it grabs the data only for the current record. For a related TO, it grabs data for all of the related records.
It’s not a traditional one-to-many relationship. This is a single table with several fields including qty, srp, and a calculated field for line total.
I think the problem is that the SUM function does not work when defining a variable.
@bdbd gave you the correct answer. It has nothing to do with variables. You’re in one table on one record: Then the scope is the current record. Make a selfjoin and use SUM for the field in the selfjoin TO. Then you will get the correct result.