Purpose:
The purpose of this post is to explain how can we make a standard field mandatory on a form in X++.
Application:
Dynamics 365 for Finance and Operations
Business requirement:
Business requirement is to make a field mandatory which is an optional field in Standard Dynamics.
Solution:
We are extending the PurchCreateOrder form in the code below and using chain-of-command, we’re extending the init method and making the Buyer group field mandatory on the form datasource.
Code
[ExtensionOf(formStr(PurchCreateOrder))]
internal final class ATLAS_PurchCreateOrder_Form_Extension
{
/// <summary>
/// Make a field mandatory.
/// </summary>
/// <remarks>
/// Atlas Dynamics Pty Ltd.
/// </remarks>
void init()
{
next init();
purchTable_DS.object(fieldNum(PurchTable, ItemBuyerGroupId)).mandatory(true);
}
}
Leave a comment