This Custom Logic is for a Custom Validation.
Code Block |
---|
language | php |
---|
title | Prevent Duplicate Charge Catalogs |
---|
linenumbers | true |
---|
|
/**
* 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; |