Skip to main content
Skip table of contents

Custom Validation Library

For details on writing a Custom Validation, please see our wiki article.

Prevent Duplicate Charge Catalog Entries

This Custom Logic is for a Custom Validation.

Prevent Duplicate Charge Catalogs

PHP
/**
 * Prevents duplicate name/type combinations in the CHRG_CATALOG table.
 *
 * Description: Prevent Duplicate CHRG_CATALOG Entries
 * Table Name: CHRG_CATALOG
 * Table Record: null
 * Action: Save
 */
$query = "SELECT RECID FROM CHRG_CATALOG WHERE NAME = '"
    . $params["charge_name"] . "' AND CHARGE_TYPE_LISTS_RECID = " . $params["type"];
$existing = $this->query($query);

if (isset($existing[0]["RECID"]) && ($existing[0]["RECID"] !== $data["RECID"]))
{
    $this->setMessage('Save failed: there already exists a Charge Catalog record with the same name/type combination');
    return false;
}
return true;

Prevent Duplicate Equipment Catalog Entries

Prevent duplicate Equipment Catalogs

Prevent Duplicate Equipment Catalog Entires

PHP
<?php
/**
 * Prevents duplicate manufacturer/manufacturer part number combinations in the EQP_CATALOG table.
 *
 * Description: Prevent Duplicate EQP_CATALOG Entries
 * Table Name: EQP_CATALOG
 * Table Record: null
 * Action: Save
 */
$query = "SELECT RECID FROM EQP_CATALOG WHERE MANUFACTURER = '"
    . $params["manufacturer"] . "' AND MANU_PART_NUM = '" . $params["manu_part_num"] . "'";
$existing = $this->query($query);

if (isset($existing[0]["RECID"]) && ($existing[0]["RECID"] !== $data["RECID"]))
{
    $this->setMessage('Save failed: there already exists an Equipment Catalog record with the same manufacturer/manufacturer part number combination');
    return false;
}
return true;

Service Orders Require Owner

This Custom Logic is for a Custom Validation.

Service Orders Require Owner

PHP
if ($data["RECID"] != "addNew" && $params['sd_type'] == 'sd-service-order' && 
    $data['SD_STATUS_LISTS_RECID'] == $this->listGetByCode('SD_STATUS', 'COMPLETE') &&
                empty($data['D_OWNER_CONTACTS_RECID']) &&
                empty($data['D_OWNER_DEPT_HIERARCHY_RECID'])
            ) {
  
                    $this->setMessage("An owner is required to complete the order. <br>" .
                                      "Please select an owner then save the record again.");
                                    return false;

            }
          //  return true;

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.