Versions Compared

Key

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

Prevent duplicate Equipment Catalogs

Code Block
languagephp
titlePrevent Duplicate Equipment Catalog Entires
linenumberstrue
<?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;