Dynamics 365 Finance & Operations: Defining delegate and calling them

In this blog, I will show how “Is default attachment” is shown in document attachment form, when user opens it from “Accounts payable > Invoices > Pending vendor invoices” and “Accounts payable > Inquiries and reports> Invoice > Invoice journal”.

This is done using delegate “ShowDefaultAttachmentField” used in DocuView form in application foundation model and handler class, DocuViewExtension class in application suite. The delegate is declared in form declaration as shown below.


The delegates instance is defined in doReSearchFormRun method which is called from doReSearch method. For a delegate to be properly handled, the delegate method declaration, the delegate instance, and the delegate handler must have the same method signature. Since delegates do not have a return value, an EventHandlerResult is passed as a parameter to provide access to the needed result value after the delegate has returned.


The delegates are shown in the events node of the form like below. Right click and click “Copy event handler method” to copy the signature.

Paste the signature in new class so that the delegate handler definition is automatically added to the class. In above case the handler is defined in DocuViewExtension class as shown below.

Comments

Popular posts from this blog

Dynamics 365 Finance & Operations Release pipelines import.

Attaching a user selected document to a purchase order using x++ job (Runnable class) in Dynamics 365 for Finance and Operations

Claude AI Models Comparison (Updated: July 2026): Haiku 4.5 vs Sonnet 5 vs Opus 4.8 vs Fable 5