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 / Override Table Methods...
Finance forum

Override Table Methods in D365

(0) ShareShare
ReportReport
Posted on by

Hello,

How can I override the implementation of a table method in an Extension class?

I am developing a custom Workflow for Sales Order, for that i need to override *CanSubmitToWorkflow* method in table. For now, according to my understanding this can only be achieved by Overlayering which definitely is not a good practice. Can someone here guide me if there is any workaround?

  • Suggested answer
    @365 Profile Picture
    15 on at
    RE: Override Table Methods in D365

    You can achieve the same through Extension

    you create an augmentation class.

    For example, a new field that is named MyInventLocationId was added to the InventTable table through extension. A data event handler was also created for the Inserting event, and you must implement the logic of filling the new field there. To encapsulate that action, you will create a new method on InventTable and name that method myDefaultInventLocationId.

    You first create a new class in the extension model. This class will augment the InventTable table, and enable access to the table's fields and methods in a manner that is easy to read and understand. It's important that you choose the correct name for your augmentation class. This name must be unique across all types in all models that are deployed.

  • Verified answer
    Sheikh Sohail Profile Picture
    6,125 on at
    RE: Override Table Methods in D365

    In D365FO extension of canSubmitToWorkflow still not available if not override on actual table. But there is an alternate on which i have recently and its working perfectly on client side.

    Please have look this blog and mark this answer as suggested if this will work for you.

    community.dynamics.com/.../avoid-over-layering-in-development-of-workflows-on-existing-form

    d365technext.blogspot.com/.../avoid-over-layering-in-development-of.html

  • Arne Verhoef Profile Picture
    on at
    RE: Override Table Methods in D365

    Can you just explain what references you have put on each model.

    I seem to get an issue when executing the page, when the code reaches the NEXT statement i get an error : "Object reference not set to an instance of an object." as if it cant find the code on the other overlay model. (PU12 / with Fall Update of D365FO)

    Any ideas ?

  • Community Member Profile Picture
    on at
    RE: Override Table Methods in D365

    Mesut,

    Thanks for sharing your observation.

    Yet again, it wasn't possible without Overlayering.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Override Table Methods in D365

    Hi Hafiz,

    I have spent 3 days to solve that problem. I have setup worfklow on InventTransferORder form so I do every pre-requirements( Workflow category, approvalis, tasks, workflow types, menuITems ettc.)at backround without no problem.

    However I could not override CansubmitToWorkflow method and so I could not activate my workflow.

    What I have done to achieve that problem: (no way without overlayering)

    1. I have two model. First is my customer main model. lets name it as CustAX365 model. second is my custom aplication suite model and run under standart application suite model and depends on it. lets name it as CustApplicationSuite365 model.
    2. I have customized InventTransfeTable TABLE on CustApplicationSuite365 level and Add CANSUBMITTOWORKFLOW method. only add, no more action.
    3. I have customized InventTransfeTable FORM on CustApplicationSuite365 level and update Workflow enabled, workflow datasource, workflow type properities on Design node of form.
    4. Then I use Chain of command and create a new class for InventTransfeTable TABLE extension and write my logic to cansubmittoWorkflow method on CustAX365 level.Than it works fine.
          1. [ExtensionOf(tableStr(InventTransfeTable))]

            final class InventTransfeTable_Coc_Extension

            {

               public boolean canSubmitToWorkflow()

               {

                   boolean ret;

                   ret = next canSubmitToWorkflow();

                  if(this.recID && this.WorkflowState == WorkflowState::notSubmitted && this.existLine())

                   {

                          ret = true;

                   }

                   return ret;

                }

            }


    5. than it works fine and workflow button displayed on form.

  • drodmarin Profile Picture
    380 on at
    RE: Override Table Methods in D365

    Hafiz, cansubmitToWorkflow method is a table method, but the table belong a form datasource.

  • Community Member Profile Picture
    on at
    RE: Override Table Methods in D365

    DavidHow can cansubmitToWorkflow method go on form? It always is a table method.
    Even if I consider its a form method, how would you place it on List Page?

  • drodmarin Profile Picture
    380 on at
    RE: Override Table Methods in D365

    Hi Hafiz,

    You have trying create a chain of command of a method that doesn't exist in the table. This method is a form method. 

    You need the following:

    [ExtensionOf(formStr(SalesTable))]
    final class SalesTable_PWTesting_Form_Extension
    {
        public boolean canSubmitToWorkflow(str _workflowType)
        {
            boolean ret;
           
            ret = next canSubmitToWorkflow(_workflowType);
     
            return ret;
        }

    }

    Regards.

  • Community Member Profile Picture
    on at
    RE: Override Table Methods in D365

    Sukrut, Simple method overriding won't work as I can't call super this way.

  • Community Member Profile Picture
    on at
    RE: Override Table Methods in D365

    David, I tried using Chain of Command, but it is giving this syntax error when i try to call canSubmitToWorkflow:

    The next method cannot be invoked in method 'canSubmitToWorkflow' because it's not a Chain Of Command Method.

    Below is the code of my class:

    [ExtensionOf(tableStr(SalesTable))]

    final class SLDSalesOrder_Extension

    {

       public boolean canSubmitToWorkflow(str _workflowType)

       {

           boolean ret;

           ret = next canSubmitToWorkflow(_workflowType);

           return ret;

        }

    }

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... 293,276 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,975 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans