COC for form data field level

 1. Validate() :- 


This method will help you to validate the selected data from filter/Lookup for a xyz condition if condition not true through error message 


 [ExtensionOf(formDataFieldStr(SalesCreateOrder,SalesTable,CustAccount))]

final class BAS_SalesCreateOrderForm_SalesTable_CustAccount_Extension
{
    public boolean validate()
    {
        FormDataObject      formDataObject = any2Object(this) as FormDataObject;
        FormDataSource      formDataSource = formDataObject.datasource();
        SalesTable          salesTable;
        CustTable           custTable;
        boolean ret =  next validate();
        salesTable = formDataSource.cursor();

 

        
        select firstonly  custTable
             where custTable.AccountNum == salesTable.CustAccount;

 


        if(custTable.BAS_DisableSalesOrder == NoYes::Yes)
        {
            ret = checkfailed("@BAS_CustomerSalesOrderLabel:Selectedcustomerisnotvalid");
        }

 

        return ret;
    }

 

}

Comments

Popular posts from this blog

How to Create a wizard in x++ d365

how to post trade agreement journals automatically using x++ code

X++ code to CREATE AND POST A TRADE AGREEMENT IN MICROSOFT DYNAMICS 365 in D365 F & O