Skip to main content
Skip table of contents

Validate the Specific Workgroup’s Labor is Billable

PHP
/**
 * Prevents a user from adding a SERVICE_DESK_LABOR item for workgroups starting with "ABC" or "XYZ"
 * if the "Billable" flag is not checked
 *
 * Description:  ABC/XYZ Project Labor Billable
 * Table Name:   SERVICE_DESK_LABOR
 * Table Record:
 * Action:       Save
 */

if (empty($params['billable'])
    && ($wkGroup = $this->query("SELECT NAME FROM WORKGROUPS WHERE RECID = {$params['workgroup']}"))
    && !empty($wkGroup[0]['NAME'])
    && preg_match('/^(ABC|XYZ).*$/', $wkGroup[0]['NAME'])
) {
    // If workgroup name STARTS with ABC or XYZ, output error message
    $this->setMessage( 'Billable must be Checked for ABC or XYZ Workgroups!');

    return false;

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.