Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Creating display methods for form extensions

Posted on by 690

Hi all

I have a requirement to add a display method to the MCRSalesQuickQuote form that displays the the product name in the language that is set on the SalesTable table if the form is called from the SalesTable form. I am using the latest version of AX and am extending rather than overlaying the form.

The way that I would do this in 2012 would be to declare a LanguageId as a global variable in the form which is initialised in the init method. Then I could reference this in a display method on the form datasource.

When an extension of the form MCRSalesQuickQuote is created it is not possible to create a display method on the form datasource.

Is there a way I can achieve this? Is it possible to reference the calling form some how if I put the display method on the table?

Thanks,
Joe

  • Michael Paul Profile Picture
    Michael Paul on at
    RE: Creating display methods for form extensions

    How are you passing this?

    Lets say you have the base D365 form SalesTable.  You add a form extension SalesTable.Extension.  In SalesTable.Extension you add two form controls.  One form control is a drop down enum with no table ds behind it, and the other is a string control in the sales lines grid populated by a display method with conditional logic based off of the aforementioned drop down control and the SalesLine table buffer.

    When you create the display method on a table extension class, you can only pass the SalesLine table buffer.  If you put a display method in a form extension class, when you configure the DataSource and DataMethod properties on the form control in the extension, it won't be found.  If you put in your form extension class display method anyway, and do not populate the DataSource, the compiler will say the method can't be found on the form.  

  • Martin Dráb Profile Picture
    Martin Dráb 228,501 Most Valuable Professional on at
    RE: Creating display methods for form extensions

    Easily - you get the form as the first parameter, therefore you can simply call its args() method. But if you use an extension class instead of the extension method (refer to Ievgen's links), you can simply refer to 'this' (the method won't be static, because you're adding an instance method).

  • JoeBrewer Profile Picture
    JoeBrewer 690 on at
    RE: Creating display methods for form extensions

    Thanks for the replies.

    How do I reference args in the static display method in the form extension class?

    Joe

  • Martin Dráb Profile Picture
    Martin Dráb 228,501 Most Valuable Professional on at
    RE: Creating display methods for form extensions

    I agree with Ievgen's suggestion. Nevertheless you don't actually have to store the language in a variable, have you? You could take the value from args every time.

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Creating display methods for form extensions

    Hi Joe Brewer,

    Did you try to use extension classes ax.help.dynamics.com/.../class-extensions ?

    Using it you can add state to a from (variable) to cache whatever you want, here is an example community.dynamics.com/.../code-behind-extension-forms-how-to-add-state-variable-and-override-methods-without-overlayering

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans