Autoset Lock Date and/or Lock Qty CheckBoxes for new PO Releases
Software: Epicor 9
Have you ever wanted to have the Lock Date or Lock Qty check boxes automatically checked when new PO Releases are created? It’s possible using a Data Directive BPM on the PORel table.
Instructions to Autoset Lock Date and Lock Qty CheckBoxes in Epicor
Navigate to System Management, select Business Process Management and then Setup.
Select Data Directives. Click the Table… button and search by table with the table name starting at “PORel.” Now, select the PORel table.
From the data directives menu select New In-Transaction Directive. Add a directive name. Make sure the Enabled check box is checked. Click the Conditions… button and add a condition to check that there is at least one added row in the ttPORel table. Optionally you can add conditions checking fields on the added PORel record.
Click the Actions… button to add a new action, “Synchronously execute ABL code.” Choose Execute code below and paste the code at the bottom of this page into the window. Click the Validate button. Click OK, then click OK again.
Your BPM should look similar to the screenshot above.
Save the BPM. Now, when a new PO release is created, the lock date and/or lock quantity check boxes will be automatically checked.
This is the code you will need:
/* Set the Lock Date checkbox and/or the Lock Qty checkbox when a new PORel is created. The Lock Date and Lock Qty checkbox values are stored in the ComXref table. COMxref.foreignKey1 = Lock Date COMxref.foreignKey2 = Lock Qty */ def var foundComxRefRecord as logical init false. def var setLockDate as character init "No". /* Set to "Yes" to set Lock Date checkbox */ def var setLockQty as character init "Yes". /* Set to "Yes" to set Lock Qty checkbox */ for each ttPORel where ttPORel.RowMod = 'A': /* Since this BPM might fire multiple times for the same PORel and Comxref records are not deleted/changed when a PORel is deleted, check to see if a Comxref record was already created for this PORel. */ Find first Comxref where COMxref.company = ttporel.Company and COMxref.file = "PORel_Mapping" and COMxref.Key1 = string(ttporel.PONum) and COMxref.Key2 = string(ttporel.POLine) and COMxref.Key3 = string(ttporel.PORelNum) exclusive-lock no-error. If available Comxref then do: /* A Comxref record already exists for this PORel. Set LockDate and/or LockQty */ Assign COMxref.foreignKey1 = setLockDate. COMxref.foreignKey2 = setLockQty. foundComxRefRecord = true. Release Comxref . End. If not foundComxRefRecord then do: /* A Comxref record does not exist for this PORel. Create a new Comxref record and set LockDate and/or LockQty */ Create COMxref. assign COMxref.company = ttporel.Company. COMxref.file = "PORel_Mapping". COMxref.Key1 = string(ttporel.PONum). COMxref.Key2 = string(ttporel.POLine). COMxref.Key3 = string(ttporel.PORelNum). COMxref.foreignKey1 = setLockDate. COMxref.foreignKey2 = setLockQty. End. End.