web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Best practice error - calling methods on forms

(0) ShareShare
ReportReport
Posted on by 995

Hi,

Can somebody help me in fixing the below BP error when calling the custom method in in a form eventhandler.

In source system (AX 2012) it is possible to dynamically call methods where the number and type of the parameters does not match with the method definition. This is not supported in AX 7, where the number and types of parameters have to match. Even if the parameters do match, the late bound call is extremely expensive. Mitigation: Use a class or interface hierarchy to provide a type safe fast call, or use the IS and AS operators to cast to a known type before calling.

Below is the code that I am using.

4300.JPG

Kindly help me

I have the same question (0)
  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Avinash,

    Have you tried setting optional parameters in your custom method so that you don't need to match the number of parameters when you call it.

    docs.microsoft.com/.../using-optional-parameters

    Optional parameters also apply to AX7.

  • AX Techie Profile Picture
    995 on at

    Hi Blue,

    Yes I used. But getting this error  when I call that method.

  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Avinash,

    Could you share your custom method code?

  • AX Techie Profile Picture
    995 on at

       public void hsoGetJournalData()

       {

           LedgerJournalTable  ledgerJournalTable;

           LedgerJournalName   ledgerJournalName;

           FormRun             element  = this;

           if (element.args().dataset() == tableNum(LedgerJournalTable))

           {

               ledgerJournalTable  = element.args().record();

               ledgerJournalName   = LedgerJournalName::find(ledgerJournalTable.JournalName);

               this.parmHSOIsRevenueReceiptJournal(ledgerJournalName.HSOIsRevenueReceiptJournal);

               this.parmHSOJournalNum(ledgerJournalTable.JournalNum);

               this.parmHSOIsJournalPosted(ledgerJournalTable.Posted);

           }

       }

  • AX Techie Profile Picture
    995 on at

    Hi all,

    Still my question is unanswered. Can you please help.

    Thanks.

  • Verified answer
    Martin Dráb Profile Picture
    239,638 Most Valuable Professional on at

    One option is moving the business logic from the form to a class. Then you can simply call methods by name and you don't need the hack with late-binding.

    If you're unable to refactor your code and the form is yours, you can let it implement an interface and call methods through this interface.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 797

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 589 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 534

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans