Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Is it possible to add ...
Finance forum
Answered

Is it possible to add a display method in form datasource through extension?

Posted on by 170

Hello.

Is it possible to add a display method in a form datasource through extension and then use it as a data method on new control added to the same form (through extension)  ?

Example:

[ExtensionOf(formDataSourceStr(formname,formdatasourcename))]
final class ABCDatasource_Extension
{
     public display str showString()
    {

       return "test" ;
    }
}

Then I add new string control to the "formname" by creating an extension of the form. I want to use showString display method as a data method for this control.

I'm getting compilation error: the method doesn't exists.

I try to use COC as much as possible and to avoid static methods.

There is similar discussion here :https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/311051/can-i-add-a-new-display-method-under-a-datasource-of-a-form-extension/, but It's an old thread.

Thank you.

  • FlorinF Profile Picture
    FlorinF 170 on at
    RE: Is it possible to add a display method in form datasource through extension?

    Hi ,

    After full model build, the method is displayed in the drop down as : InventOnhandItem_FormDataSource_Extension.expirationDate

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,419 on at
    RE: Is it possible to add a display method in form datasource through extension?

    It had worked for me a couple of weeks back when it showed the data method in the drop down. Could you try doing a build of your Dev model and check if that gets the drop down working?

  • FlorinF Profile Picture
    FlorinF 170 on at
    RE: Is it possible to add a display method in form datasource through extension?

    Hi Gunjan,

    It's working if you provide the full path to the method as you said : InventOnhandItem_FormDataSource_Extension.expirationDate

    I was expecting to see the method in the drop down, but it's not listed

    Thank you.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,419 on at
    RE: Is it possible to add a display method in form datasource through extension?

    Hi FlorinF,

    You should be able to choose the data method from the drop down. You can try this value as well - InventOnhandItem_FormDataSource_Extension.expirationDate

  • FlorinF Profile Picture
    FlorinF 170 on at
    RE: Is it possible to add a display method in form datasource through extension?

    Hi Martin ,

    I have the following code :

    [ExtensionOf(formDataSourceStr(InventOnhandItem, InventSum))]

    final class InventOnhandItem_FormDataSource_Extension

    {

       display date expirationDate(InventSum _inventSum)

       {

           return today();

       }

    }

    pastedimage1615066181035v1.png

    The error is :

    Severity Code Description Project File Line Suppression State
    Error Path: [AxFormExtension/InventOnhandItem.xx/Controls/FormExtensionControlk0ln0vls1/ExpirationDate/DataMethod]:The data method 'expirationDate' was not found on the data source 'InventSum' or its base table/view. 

    My version is:

    Application release

    Microsoft Dynamics 365 for Finance and Operations (10.0.15)

    Platform release
    Update39 (7.0.5816.41512)
    Thank you.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 227,996 Super User 2024 Season 2 on at
    RE: Is it possible to add a display method in form datasource through extension?

    If I'm not mistaken, it's supported now, although it wasn't possible in some older versions of D365FO.

    Neverthelss your method isn't correct - if a display method isn't on a table, it must take a table buffer as the parameter.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 227,996 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans