show the summary of a column of a grid in a new field

Hello,

I have a form where I have a grid with BOM as Master/Detail Form and a new field. Now I have to calculate the total material cost of the BOM and show it in a new field.

Grid: [TABLE=“border: 1, cellpadding: 1, width: 500”]
[TR]
[TD]part [/TD]
[TD]qty [/TD]
[TD]price [/TD]
[/TR]
[TR]
[TD]xxxx[/TD]
[TD]10[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]yyyy[/TD]
[TD]5[/TD]
[TD]2[/TD]
[/TR]
[/TABLE]
New Field
should show: 20
calculated with this formula (101 + 52)

How can I do that in SC?

BR
Christina

You can use a variable in OnRecord event for total. [MyTotal] = [MyTotal] + {qty} * price;

i Think

[MyTotal] = [MyTotal] + {qty} * {price};

Yes. Correct.

OK thanks. But how can I say my form that the total price is calculated now in the BOM? Remember my BOM is added in “Master/Detail Form”
I tried to play around with the global variable, but it doesn’t work.

I assume procedure to start a form is this way.
1. Form is starting:
onScriptInit:
[MyTotal] = 1;
{material_cost_1} = [MyTotal];

2. then is the BOM as Grid is starting since its a “Master/Detail Form”.
in onRecord:
[MyTotal] = [MyTotal] + {qty} * {price1};

3. So [MyTotal] is 1

But should be 20.

What do I do wrong?

Please refer

http://www.scriptcase.net/scriptcase-samples/php-form/master-detail/

in this case Price Order is your MyTotal.