Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 2021.3

This Custom Logic is for a Custom Validation.

Code Block
languagephp
titlePrevent Duplicate Charge Catalogs
linenumberstrue
/**
 * 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;