By default, when selecting a value for BusinessUnit or Department in Microsoft Dynamics AX, the system checks whether the specified value exists at the source level. If the value is available, it allows the change. However, if the dimension value is suspended or not activated, the system still permits the record to be saved, only issuing a warning message.
My requirement is to ensure that if the department or BusinessUnit is suspended or has an "active to" date that is earlier than the transaction date, the system should not allow the record to move forward. Instead, it should prevent the action and display an error message. To achieve this i have written below code
[ExtensionOf(formDataSourceStr(PurchTable, PurchTable))]
public final class PurchTableDS_Extension
{
int active()
{
PurchTable purchtable = this.cursor();
DimensionEntryControl DimensionEntryControlHeader;
DimensionEntryControlHeader = this.formRun().design().
controlName(formControlStr(PurchTable, DimensionEntryControlHeader));
int ret = next active();
if (purchTable.AccountingDate)
{
DimensionEntryControlHeader.parmNonActiveValueErrorTolerance(ErrorTolerance::Error);// This is
DimensionEntryControlHeader.parmActiveValueFilterDate(purchTable.AccountingDate);
}
return ret;
}
void create(boolean append)
{
next create(append);
PurchTable purchtable = this.cursor();
DimensionEntryControl DimensionEntryControlHeader;
DimensionEntryControlHeader= this.formRun().design().
controlName(formControlStr(PurchTable, DimensionEntryControlHeader));
if (purchTable.AccountingDate)
{
DimensionEntryControlHeader.parmNonActiveValueErrorTolerance(ErrorTolerance::Error);
DimensionEntryControlHeader.parmActiveValueFilterDate(purchTable.AccountingDate);
}
}
}