SuiteCRM 8 Operators

When making these changes be sure to make them in the custom directory, ie: 'public/legacy/custom/modules/<module>/…​'

When adding this configuration, it can be added to the vardefs.php or the detailviewdefs.php.

SuiteCRM 8 has 6 operators that can be used in configuration.

Greater than

<?php
...

    'name' => 'annual_revenue',
    'comment' => 'Annual revenue for this company',
    'label' => 'LBL_ANNUAL_REVENUE',
    'logic' => [
        'display' => [
            'key' => 'updateValue',
            'modes' => ['detail', 'edit', 'create'],
            'params' => [
                'fieldDependencies' => [
                    'employees',
                ],
                'targetValue' => '1000',
                'activeOnFields' => [
                    'employees' =>     [
                        'operator' => 'greater-than',
                        'value' => 10
                    ],
                ]
            ]
        ],
    ]

...

In the example above, the Annual Revenue updated to 1000 if Employees is greater than 10.

Is Empty

<?php
...

    'name' => 'description',
    'comment' => 'Full text of the note',
    'label' => 'LBL_DESCRIPTION',
    'displayLogic' => [
        'hide_on_website' => [
            'key' => 'displayLogic',
            'modes' => ['detail', 'edit', 'create'],
            'params' => [
                'fieldDependencies' => [
                    'website',
                ],
                'targetDisplayType' => 'none',
                'activeOnFields' => [
                    'website' => [['operator' => 'is-empty']]
                ]
            ]
        ],
    ]

...

In the example above we are hiding the description field if the website field is empty.

Is Equal

<?php
...

    'name' => 'annual_revenue',
    'comment' => 'Annual revenue for this company',
    'label' => 'LBL_ANNUAL_REVENUE',
    'logic' => [
        'display' => [
            'key' => 'updateValue',
            'modes' => ['detail', 'edit', 'create'],
            'params' => [
                'fieldDependencies' => [
                    'employees',
                ],
                'targetValue' => '1000',
                'activeOnFields' => [
                    'employees' =>     [
                        'operator' => 'is-equal',
                        'value' => 10
                    ],
                ]
            ]
        ],
    ]

...

In the example above when employees is 10, update Annual Revenue to 1000.

Less Than

<?php
...

    'name' => 'annual_revenue',
    'comment' => 'Annual revenue for this company',
    'label' => 'LBL_ANNUAL_REVENUE',
    'logic' => [
        'display' => [
            'key' => 'updateValue',
            'modes' => ['detail', 'edit', 'create'],
            'params' => [
                'fieldDependencies' => [
                    'employees',
                ],
                'targetValue' => '500',
                'activeOnFields' => [
                    'employees' =>     [
                        'operator' => 'less-than',
                        'value' => 5
                    ],
                ]
            ]
        ],
    ]

...

In the example above, the Annual Revenue updated to 1000 if Employees is less than 10.

Not Empty

<?php
...

    'name' => 'annual_revenue',
    'comment' => 'Annual revenue for this company',
    'label' => 'LBL_ANNUAL_REVENUE',
    'logic' => [
        'display' => [
            'key' => 'updateValue',
            'modes' => ['detail', 'edit', 'create'],
            'params' => [
                'fieldDependencies' => [
                    'employees',
                ],
                'targetValue' => '1',
                'activeOnFields' => [
                    'employees' =>     [
                        'operator' => 'not-empty',
                    ],
                ]
            ]
        ],
    ]

...

In the example above if the Employee field has any value, then Annual Revenue will update to have the value 1.

Not Equal

<?php
...

    'name' => 'annual_revenue',
    'comment' => 'Annual revenue for this company',
    'label' => 'LBL_ANNUAL_REVENUE',
    'logic' => [
        'display' => [
            'key' => 'updateValue',
            'modes' => ['detail', 'edit', 'create'],
            'params' => [
                'fieldDependencies' => [
                    'employees',
                ],
                'targetValue' => '50000',
                'activeOnFields' => [
                    'employees' =>     [
                        'operator' => 'not-equal',
                        'values' => ['10']
                    ],
                ]
            ]
        ],
    ]

...

In the example above, if the employees field is not equal to 10 then the value will be updated to 50000.

You can add the check to more than one value by adding more values:

    'employees' => [
        'operator' => 'not-equal',
        'values' => ['10', '15', '25']
    ],

Other Information

You can also use multiple operators on the same field:

<?php
...

    'name' => 'industry',
    'comment' => 'The company belongs in this industry',
    'label' => 'LBL_INDUSTRY',
    'displayLogic' => [
        'hide_on_name' => [
            'key' => 'displayType',
            'modes' => [
                0 => 'detail',
                1 => 'edit',
                2 => 'create',
            ],
            'targetDisplayType' => 'none',
            'params' => [
                'fieldDependencies' => [
                    'employees'
                ],
                'activeOnFields' => [
                    'employees' => [
                        //AND
                        [
                            'operator' => 'greater-than',
                            'value' => 5
                        ],
                        [
                            'operator' => 'less-than',
                            'value' => 25
                        ],
                        [
                            'operator' => 'not-equal',
                            //OR
                            'values' => [15, 20]
                        ],
                        ['operator' => 'not-empty'],
                    ],
                ],
            ],
        ],
    ],


...

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.