Hi folks,
It's been long time when I published my last blog but here I am with another useful blog.
Since, over layering is not allowed anymore in D365 Fin Ops but there is a way to extend MS classes by using Chain of Command.
Requirement:
I had one requirement where in default financial dimensions from PO line should be automatically populated to Fixed Asset default financial dimension if Fixed Asset is created from Product Receipt posting.
MS doesn't provide any solution to this requirement and I had to customize to fulfil this requirement.
Solution:
While debugging, I found a class that handles the logic of Product receipt posting.
I extended the logic of standard MS class "PurchPackingSlipJournalPost" method "updateAssetBook" by using Chain of Command.
Below is the example:
//Adding below attribute of "ExtensionOf" is the must to extend any standard MS class.
[ExtensionOf(classStr(PurchPackingSlipJournalPost))]
final class PurchPackingSlipJournalPost_Extension
{
protected void updateAssetBook(PurchParmLine _purchParmLine,
PurchParmLine_Asset _purchParmLine_Asset,
AssetParameters _assetParameters,
AssetGroup _assetGroup,
AssetTable _assetTable)
{
AssetBook assetBook;
//This is where I used next chain of command which will first execute the logic of MS and then my logic will be executed as I wrapped the method in such a way that my logic is written after next call if my logic was written before next call then before MS logic my logic would have been executed which i didn't want. As per my requirement I wanted MS classes to be executed first so that I can get Purchline rec id reference from the Fixed Asset created after Product receipt posting and from that I can populate Purchline default dimension to Fixed Asset default dimension.
next updateAssetBook(_purchParmLine, _purchParmLine_Asset, _assetParameters, _assetGroup, _assetTable);
PurchLine purchLine = purchLine::findRecId(_assetTable.PurchLineRecId);
if(purchLine)
{
//This will update Fixed asset default dimension same as PO line default dimension
update_recordset assetBook
setting DefaultDimension = purchLine.DefaultDimension
where assetBook.AssetId == _assetTable.AssetId;
}
}
}
*This post is locked for comments