Hi all,
I’m working on a M/D and I insert on Detail part a sc_master_value that makes some SUM on rows values.
It work nice only when I work and edit remaining on detail part of M/D form but when I load the form for the first time the two total fields that are on Master part remain always empty.
I do the calculation on
- onScriptInit
- onLoadRecord
- onLoad
- onValidateSuccess
- onAfterInsert
- onAfterUpdate
I did a lot of test without success.
Have you got idea wich could be my mistake ?
Thanks
I made a PHP method that do the following calculations and then I call it on the above events:
$sql_ordervalue1 = "SELECT SUM(pricequantityOrderedexchange_rate) FROM orderdetails WHERE orderNumber = {orderNumber} ";
sc_lookup(total_order1, $sql_ordervalue1);
$tot_order_value = {total_order1[0][0]};
sc_format_num($tot_order_value, ‘.’, ‘,’, 2, ‘S’, ‘1’, ‘’);
sc_master_value(‘tot_order_value’, $tot_order_value);
$sql_ordervalue2="SELECT SUM(pricequantityOrderedexchange_rate*(SELECT VarPerc
FROM vatrates
WHERE VatID
= {VatRate})) FROM orderdetails WHERE orderNumber = {orderNumber} ";
sc_lookup(total_order2,$sql_ordervalue2);
$tot_order_value_vat = {total_order2[0][0]};
sc_format_num($tot_order_value_vat, ‘.’, ‘,’, 2, ‘S’, ‘1’, ‘’);
sc_master_value(‘tot_order_vat_incl’, $tot_order_value_vat);