Required Dependency but with a positive value

I am using a Dependency file (for other needs) and want to 'require' that a Currency field has a positive value when the conditions are true.

However, normal 'Required' only seems to test that the field has content, and in the case of a Currency (number) field, this includes 0.00

I have tried including a check on the value in the trigger but that has no effect (normal Required works using the $account_type test)

Ideas welcome.

Thanks

Code in Dependency file:

$dependencies['Accounts']['required_feeslost'] = array(

'hooks' => array("edit"),
'trigger' => 'and(isInList($account_type, createList("2")), equal($symc_lost_fees_c, 0.00))',
'triggerFields' => array('account_type'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetRequired',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'symc_lost_fees_c',
'value' => 'true',
),
),
),
'notActions' => array(
array(
'name' => 'SetRequired',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'symc_lost_fees_c',
'value' => 'false',
),
),
),
);

I've also tried a variation on the above, based on some guidance in the Sugar Developer documentation, but still no joy

Switching the conditional logic to the Value line and testing the value of the field

$dependencies['Accounts']['required_feeslost'] = array(
'hooks' => array("edit"),
'trigger' => 'true',
'triggerFields' => array('account_type'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetRequired',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'symc_lost_fees_c',
'value' => 'and(isInList($account_type, createList("2")), not(greaterThan($symc_lost_fees_c, 0.00)))',
),
),
),
'notActions' => array(
array(
'name' => 'SetRequired',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'symc_lost_fees_c',
'value' => 'false',
),
),
),
);

  • Perhaps you can try this formula:

    and(isNumeric(toString($symc_lost_fees_c),greaterThan($symc_lost_fees_c,0))

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi

    Thanks for coming back on that. I have tried the formula but no success yet. I did test the formula by making another field's visibility dependent on the value within the Lost fees field and that is working, suggesting the formula is correct. For example, if the Lost fees = 0 the other field is visible. As soon as I enter a positive value in the Lost fees, the other field disappears.

    I'm thinking that the $0.00 initial value on the currency field is overriding the 'Required' functionality. I ensured that the Default on that field was not 0.00 but I think because it is a currency field it automatically initialises ad $0.00 and somehow overrides the 'required' functionality.

    I will do some further experimentation and let you know if I get anywhere.

    Neil