Skip write and validateWrite in form extensions with #MsDyn365FO platform update 22
Class CustTransD365CustInvoiceJourFDS_Extension in Visual Studio

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;

   }


}

Does not work for datasources added in another extension.

Like
Reply

I get the error "chain of command method must contain one next call".

Like
Reply

To view or add a comment, sign in

More articles by Paul Heisterkamp

Others also viewed

Explore content categories