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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to call extension method in form data source?

(0) ShareShare
ReportReport
Posted on by 573

Hi experts,

I create a method in extension of InventOnHandItem\Data Source\InventSum.

private InventBatch dWFS_InventBatch(InventSum _inventSum)
{
InventBatch inventBatch;
InventDim inventDimLocal = _inventSum.joinChild();

if (inventDimLocal.inventBatchId)
{
inventBatch = InventBatch::find(inventDimLocal.inventBatchId, _inventSum.ItemId);
}

return inventBatch;
}

Now I wants to call this method in another display method like follow

[SysClientCacheDataMethod]
public static display InventBatchExpDate dWFS_ExpDate(InventSum _inventSum)
{

return DWFS_InventOnhandItem_FormDSInventSum_Extension::dWFS_InventBatch(_inventSum).expDate;
}

And error found "Static method 'dWFS_InventBatch' cannot be called through class 'DWFS_InventOnhandItem_FormDSInventSum_Extension'. Please use instead the extended type 'InventOnhandItem'.

Would you please tell me how to call correctly?

Thanks.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    I'm not 100% sure if it's even possible. But if it is, you indeed need to call it via InventOnHandItem FormRun, just like you would call any method on that form and it's data sources. The extension methods, fields etc are always supposed to be reached just like the fields in the base object. You are adding methos, fields etc to the base object! You should not try to call them via the extension class. Assuming both methods are in the same data source, you should be able to call the other method simply via "this.methodName()" (once you've implemented everything properly, and assuming it's supported to call form ds extension methods which I'm not sure about).

    Also, some details which will anyway cause issues:

    - You try to call a static method (DWFS_InventOnhandItem_FormDSInventSum_Extension::dWFS_InventBatch(_inventSum) but your method is not static

    - Your method is private so it should not even be possible to call it from outside the class

    - Why did you make the other method static and the other one not? Neither one needs to be static. And neither one should have _inventSum parameter (assuming they're not static)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans