Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

For a form extension, can we write the code for form data source, field and form in the same class

Posted on by 31
Hi there,
 
I think I saw somewhere that you could define a class like below i.e. have the DataSource, DataField, and the the init method of a form in the same class instead of creating new classes for each type of form control.
 
  • [ExtensionOf(formStr(SalesCreateOrder))]final class SalesCreateOrder_Extension{public void init(){        next();        //some forminit related code here    }    [DataSource]    class TMSSalesTable    //datasource related code here{public void write()        {            super();            if (!tmsSalesTable.mustBeSaved())            {                TMSSalesTable blankTMSSalesTable;                TMSSalesTable.data(blankTMSSalesTable);            }        }        public boolean validateWrite()        {            if (!tmsSalesTable.SalesId)            {                tmsSalesTable.SalesId = salesTable.SalesId;            }            return super();        }        [DataField]      //code here related to the datafield of the data source above  class CarrierCode        {            public void modified()            {                //some code here                super();            }        }    }}
 
 
Unfortunately though, my methods are not being hit and even the breakpoint doesn't load.
Could someone please confirm if the above syntax is allowed?

Apologies for the formatting, I have tried about 6 times, but it resets to straight lines
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    For a form extension, can we write the code for form data source, field and form in the same class
    No, it's not possible.
     
    Moved from D365 general forum to the Finance forum, because it's clearly about F&O and not about D365 in general.
  • Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    For a form extension, can we write the code for form data source, field and form in the same class
    Hi,
     
    Hi Partner,
    Which app are you using in Dynamics 365?
    After some searching, I found that it has something to do with .
     How to write the extension class for Existing Forms (dynamics.com)

    If so, you need post the question in the following forum for further help:

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans