Calculated total fields not working if marked read only

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
kevinm
Posts: 10
Joined: 2013-10-31 09:31

Calculated total fields not working if marked read only

Post by kevinm » 2019-05-12 08:02

Just in case anyone else is having a problem with populating calculated fields from hooks, this might save some time...

This won't work if the Total fields 'Read Only' checkbox is ticked:

Code: Select all

function tablename_before_update(&$data, $memberInfo, &$args){
     
    // calculate total after applying discount
    $data['total'] = $data['subtotal'] * (1 - $data['discount'] / 100);
     
    // calculate total after applying sales tax 
    $data['total'] = $data['total'] * (1 + $data['sales_tax'] / 100); 
     
    return TRUE;
}
The only way I found to do it was through a seperate SQL update statement.

Post Reply