
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'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)