Skip write and validateWrite in form extensions with MsDyn365FO platform update 22

In the older days of Microsoft Dynamics 365 for Finance and Operations you could add read only datasources to almost every form. To do so you had to overwrite the methods write and validateWrite on form datasource level and skip the super call.

In the newer days this was not possible, because it was simply not possible/allowed to skip the super or next call in the methods write and validateWrite on the form datasource.

With platform update 22 and Ref# 198754 this is possible again as you can read here: https://docs.microsoft.com/en-us/business-applications-release-notes/October18/dynamics365-finance-operations/platform-extensibility3

To show you the new extensibility feature I add the form datasource CustInvoiceJour to the form CustTrans. The feature behind the new datasource is that I want to show the CustomerRef from the linked CustInvoiceJour. As there is not always a CustInvoiceJour for each CustTrans I added the new datasource with link type OuterJoin. Regardless of the properties allow create/delete/edit, when the user hits save (Strg+S) in this form, the methods write and validateWrite will be called. To skip write and validateWrite you will need the following code extension for the added form datasource:

/// <summary>

/// Code extension class for form datasource D365CustInvoiceJour in form CustTrans.

/// </summary>

[ExtensionOf(formdatasourcestr(CustTrans, D365CustInvoiceJour))]

final class CustTransD365CustInvoiceJourFDS_Extension

{

   /// <summary>

   /// Upon saving the top level <c>CustTrans</c> record, <c>D365CustInvoiceJour</c> attached by outer join will be processed inline because both datasources act together.

   /// In this case write() should not be executed.

   /// </summary>

   public void write()

   {

       // next write();

   }

   /// <summary>

   /// Upon saving the top level <c>CustTrans</c> record, <c>D365CustInvoiceJour</c> attached by outer join will be processed inline because both datasources act together.

   /// In this case validateWrite() should not be executed.

   /// </summary>

   public boolean validateWrite()

   {

       boolean ret = true;

       // ret = next validateWrite();

       return ret;

   }

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s