如何在 Acumatica 中有条件地要求字段?

How to make field conditionally required in Acumatica?

假设我的 DAC class 有两个字段。 Boolean(我们将其命名为 IsDateRequired)和 DateTime(我们将其命名为 DateReceive)。是否可以仅在 IsDateRequired 等于 true 的情况下才需要字段 DateReceive?

要有条件地使字段成为必填字段,您需要在 _RowSelected 事件处理程序中使用 PXDefaultAttribute.SetPersistingCheck<DAC.Field>(pxcache, data, PXPersistingCheck.<Value>) 方法。

PXPersistingCheck.Nothing 将使字段成为非必填项,而 PXPersistingCheck.Null/PXPersistingCheck.NullOrBlank 将使字段成为必填项。 您需要确保为 DAC 字段声明了 PXDefault 属性,您正试图有条件地将其设为强制性。如果没有声明 PXDefault 属性,PXDefaultAttribute 的静态方法将不会有任何影响。