Document toolboxDocument toolbox

(2024.1) Prevent Duplicate Charge Catalog Entries

This Custom Logic is for a (2024.1) Custom Validation.

Prevent Duplicate Charge Catalogs
/** * 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;