Search code examples
erpacumatica

How to make field conditionally required in Acumatica?


Let's say I have DAC class with two fields. Boolean ( let's it's name is IsDateRequired ) and DateTime ( let's name it DateReceive ). Is it possibel to make field DateReceive required only in case if IsDateRequired equal to true?


Solution

  • To make field mandatory conditionally, you need to use PXDefaultAttribute.SetPersistingCheck<DAC.Field>(pxcache, data, PXPersistingCheck.<Value>) method in _RowSelected event handler.

    PXPersistingCheck.Nothing will make field non-mandatory and PXPersistingCheck.Null/PXPersistingCheck.NullOrBlank will make field mandatory. You need to make sure to have PXDefault attribute declared for the DAC field you are trying to make it mandatory conditionally. Without PXDefault attribute declared, static methods of PXDefaultAttribute will not have any impact.