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;