I was working on a client project in Acumatica and stumbled across the PXCheckUnique attribute. This handy attribute allows the system to ensure that field values are unique that aren’t a part of the unique key defined for the table.
PXCheckUnique
Allows you to control unique values in a grid for a specified set of criteria.
Example:
[PXCheckUnique(Where = typeof(Where<CWUnitAssignLine.unitID, Equal<Current<CWUnitAssignLine.unitID>>, And<CWUnitAssignLine.assignType, Equal<Current<CWUnitAssignLine.assignType>>>>))]
When applied to a field in a DAC, it will cause the DAC to enforce uniqueness for that field for the current unit and assignment type. This is helpful when the unique key for the table might be some other combination of values.
There are other syntax formats that you can use. This would be identical except that it uses the ClearOnDuplicate flag to dictate how to handle a duplicate.
[PXCheckUnique(typeof(CWUnitAssignLine.unitID), typeof (CWUnitAssignLine.assignType) , typeof(CWUnitAssignLine.sortOrder),ClearOnDuplicate =true)]
If you have questions or need some assistance, visit our support page for more help.