Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Using Chain of Command...
Finance forum

Using Chain of Command for Form Datasource and Form Controls.

(0) ShareShare
ReportReport
Posted on by

Hi All,

Since the arrival of chain of command, we have the possibility to use class variables and add code to protected methods in the chain. 

I am trying to make an extension class for a form, with the use of the decorater as followed for example  [ExtensionOf(formStr(SalesCopying))].

And using a public final class of my newly created class for the SalesCopying form.

This gives us the possibility to use CoC on methods of the form itself, but how can I use chain of command on datasource methods or on control methods?

Since every datasource and control has its own class now in 365 , I don't know how to use the decorater for my form extension class to use CoC on underlying methods on datasource and controls.

Do you have to make an extension class for every datasource and control you want to use CoC with, if so how do you distinguish this?

Thanks in advance,

Tom 

  • Martin Dráb Profile Picture
    231,758 Most Valuable Professional on at
    RE: Using Chain of Command for Form Datasource and Form Controls.

    CoC on form datasources and controls is supported since PU20 (therefore it indeed wasn't possible when the topic was discussed in this thread).

  • Suggested answer
    Pavel Vorontsov Profile Picture
    20 on at
    RE: Using Chain of Command for Form Datasource and Form Controls.

    Hi, 

    It seems like you can use dataSource methods in chain of command, but extension class should extend dataSource. Something like:

    [ExtensionOf(formDataSourceStr(WMSPickingRegistration, WMSOrderTrans))]

    final class WMSPickingRegistrationWMSOrderTrans_Extension
    {
    public void write()

    {
    WMSOrderTrans wmsOrderTrans = this.cursor();
    InventDimId inventDimIdOrig = wmsOrderTrans.orig().InventDimId;
    next write();
    }

    Not sure about controls.

  • Verified answer
    Fedir Kryvyi Profile Picture
    1,026 on at
    RE: Using Chain of Command for Form Datasource and Form Controls.

    Hi Tom,

    "So basically we need to use data events for the datasources and controls for those methods?"

    Yes, basically you need to have eventHandlers for event that are fired from datasources|controls|form separately.

    "What about our custom made methods, we can’t add those to an extension class if they are under a datasource."

    No, you cannot add your custom methods to DS on class extension. However, usually this is the problem with edit methods, all other methods can be moved to a form level with some tricks. So the pipeline is

    1. Move your custom methods from DS level to Form level

    2. Move your custom form-level code to Extension class

    3. Create evenHandlers for required events

    4. Call your custom method using formhasmethod()onstruction

    In this way you can also override methods like lookup, jumpRef, modified etc. for DS fields

    Here is an article that might be useful: ievgensaxblog.wordpress.com/.../ax-7-how-to-override-form-data-source-field-methods-without-overlaying

  • Community Member Profile Picture
    on at
    RE: Using Chain of Command for Form Datasource and Form Controls.

    Hi Fedir,

    Thank you for your reply, what I meant to say by every datasource is it’s own seperate class with it’s own methods. Your answer for data events makes sense, however what if you have a same type of method on the form itself and on the data source like the init method or modified method. If you compare a form object with the compare and merge tool you can see the class name  for the form itself and a class name for every control and datasource of that form. With a decerator called [DataSource] for example. Not the ds object where you want to call the refresh reread method for example. So basically we need to use data events for the datasources and controls for those methods? What about our custom made methods, we can’t add those to an extension class if they are under a datasource. Thanks for your answer it will help us, but we still have somethings that we need to figure out to remove all overlayering adjustments.

    Greetings Tom,

  • Suggested answer
    Fedir Kryvyi Profile Picture
    1,026 on at
    RE: Using Chain of Command for Form Datasource and Form Controls.

    Unfortunately you cannot use CoC on form datasources yet. I have heard that it might be added in future releases.

    The only option is to use eventhandlers for form datasource events.

    "Since every datasource and control has its own class now in 365" - what do you mean by that? you cannot implicitly instantiate an object of something like SalesTable_ds. They all are jusr FormDataSourceObjects so there is no way to create Extension objects for them at the moment

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,758 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans