Is it possible to overwrite calculated fields?

Hi, 

I am wondering - is it possible to overwrite calculated fields? 

I have a calculated field (Total Contract Value) which is calculated based on ARR and subscription duration. But there are some exceptions to the formula. Rather than altering the formula, is it possible to edit the field, so that I can overwrite the calculated value and input it manually?

Thanks!

Ada

Parents
  • Hello

    A possible way to do this is to migrate the logic that you currently have in the calculated formula into a SetValue Dependency 
    This will allow you to decide your desired rules to set the field read-only/calculated.

    For example, you could use a checkbox field to allow the user to enable the contract value to be overridden, something like this: 

    <?php
    
    //path custom/Extension/modules/Opportunities/Ext/Dependencies/handle_contract_value.php
    
    $dependencies['Opportunities']['handle_contract_value'] = array(
        'hooks' => array("edit", "view"),
        'trigger' => 'true',
        'triggerFields' => array('override_value_manually_c'),
        'onload' => true,
        'actions' => array(
            array(
                'name' => 'SetValue',
                'params' => array(
                    'target' => 'total_contract_value_c',
                    'value' => 'ifElse(equal($override_value_manually_c,false),<yourCurrentFormulaHere>,$total_contract_value_c)'
                )
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'total_contract_value_c',
                    'value' => 'equal($override_value_manually_c,false)', 
                ),
            )
        )
    );


    I hope this helps. 

    André

Reply
  • Hello

    A possible way to do this is to migrate the logic that you currently have in the calculated formula into a SetValue Dependency 
    This will allow you to decide your desired rules to set the field read-only/calculated.

    For example, you could use a checkbox field to allow the user to enable the contract value to be overridden, something like this: 

    <?php
    
    //path custom/Extension/modules/Opportunities/Ext/Dependencies/handle_contract_value.php
    
    $dependencies['Opportunities']['handle_contract_value'] = array(
        'hooks' => array("edit", "view"),
        'trigger' => 'true',
        'triggerFields' => array('override_value_manually_c'),
        'onload' => true,
        'actions' => array(
            array(
                'name' => 'SetValue',
                'params' => array(
                    'target' => 'total_contract_value_c',
                    'value' => 'ifElse(equal($override_value_manually_c,false),<yourCurrentFormulaHere>,$total_contract_value_c)'
                )
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'total_contract_value_c',
                    'value' => 'equal($override_value_manually_c,false)', 
                ),
            )
        )
    );


    I hope this helps. 

    André

Children
No Data