Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

...

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

...