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 224,528 Super User 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 224,528 Super User 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,274 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

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,632 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,528 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans