Make a quick vote 🗳 ️How do you refer to SuiteCRM extensions: add-ons or plug-ins? Click here to have your say 👈

See value of fetched_row inside controller.php

Is there a way to see the field changes inside the controller?

For example for the price field the 2 below are always identical, it always shows the latest value


I know it works in logic hooks, but is there a way to compare before and after values inside the controller?

Check here for some ideas:


1 Like

Thank you, currently without JS I just use the following function to query the audit table. So you would need to make sure the field is auditable. It’s the equivalent of getting the fetched_row value

// Will fetch last price in audit table, if no price was previously set then return false
function get_last_price($tbl, $id) {

    $query = 'SELECT before_value_string FROM '.$tbl.' WHERE field_name="price_c" AND parent_id="'.$id.'" ORDER BY date_created DESC LIMIT 1;';

    if($result = $GLOBALS["db"]->query($query)) {

        // If price didn't change return false
        if($result->num_rows == 0) {
            return false;
        elseif($row = $result->fetch_assoc()) {
            return $row["before_value_string"];



And I also use it inside the following function just to check if the price has changed or not

// If price has changed return true
function price_change_controller($tbl, $bean) {

    // Current price
    $current_price = $bean->price_c;

    // If we were able to fetch a price from audit table then compare new price vs old price
    if(($last_price = get_last_price($tbl, $bean->id)) !== false) {
        if($current_price != $last_price)
            return true;

    // Check if the price is not NULL, if not return true, because it means the price went from nothing to something
        return true;

    // If none of the above worked return false
    return false;

1 Like