Search code examples
axaptax++dynamics-ax7d3fo

AX7: Creating a method on a View using the extension method (bug?)


Edit: The question is, why won't a display method on a view work?

I'm trying to use the extension method to create a display method on the DirPartyPostalAddressView and as far as I can tell, this might be an AX7 bug or I'm doing it wrong. I'm on the latest AX7 with the recent update.

I'm using the method detailed here https://blogs.msdn.microsoft.com/mfp/2015/12/15/x-in-ax7-extension-methods/

I created a proof of concept display method for use on the view DirPartyPostalAddressView vs table CustTable to show the possible bug.

Extension class code:

static class MyClass_extension
{
    public static display NoYesId displayYesDirPartyPostalAddressView (DirPartyPostalAddressView _this)
    {
        return NoYes::Yes;
    }

    public static display NoYesId displayYesCustTable (CustTable _this)
    {
        return NoYes::Yes;
    }
}

I create an extension of the form CustTable, add a checkbox control to it, set the DataSource = CustTable and DataMethod = MyClass_extension::displayYesCustTable and this works correctly. (See screenshots)

CodeChanges

Working image

The Issue: I created an extension of the form LogisticsPostalAddressGrid, add a checkbox control to the grid, set the DataSource = DirPartyPostalAddressView and it does not compile. (See screenshot)

The error is:

The data method 'MyClass_extension::displayYesDirPartyPostalAddressView' was not found on the data source 'DirPartyPostalAddressView' or its base table/view.

Non-compiling


Solution

  • This has been confirmed as a bug and will be fixed in the next platform release.

    See: https://connect.microsoft.com/site1321/feedback/details/3100997/data-methods-are-not-found-using-extension-method-on-views