I was getting the below error while trying to copy the purchase order lines from another order.And also specifically I'm getting this for inter-company purchase orders.
Object reference not set to an instance of an object Error.
Reason:
In my case there is an extension class for InterCompanySyncPurchLineType-> synchronizeInTradeCompany.
and I was initializing next synchronizeInTradeCompany(); code after AxSalesLine.
Object reference not set to an instance of an object Error.
Reason:
In my case there is an extension class for InterCompanySyncPurchLineType-> synchronizeInTradeCompany.
and I was initializing next synchronizeInTradeCompany(); code after AxSalesLine.
[ExtensionOf(classStr(InterCompanySyncPurchLineType))]
final class SWInterCompanySyncPurchLineType_Extension
{
protected void synchronizeInTradeCompany()
{
AxSalesLine axSalesLineLocal = this.axSalesLine;
next synchronizeInTradeCompany();
if (create || purchLine.fieldChanged(fieldNum(PurchLine, InventDimId)))
{
axSalesLineLocal.axInventDim().productDimensions(axInventDim);
changecompany (purchLine.company())
{
this.copyPurchaseBatchNumberToSalesTable(purchLine);
}
}
}
}
Solution: AxSalesLine doesn't get initialized until after the call to synchronizeInTradeCompany.
So, I swapped the code as shown below.
[ExtensionOf(classStr(InterCompanySyncPurchLineType))]
final class SWInterCompanySyncPurchLineType_Extension
{
protected void synchronizeInTradeCompany()
{
next synchronizeInTradeCompany();
AxSalesLine axSalesLineLocal = this.axSalesLine;
if (create || purchLine.fieldChanged(fieldNum(PurchLine, InventDimId)))
{
axSalesLineLocal.axInventDim().productDimensions(axInventDim);
changecompany (purchLine.company())
{
this.copyPurchaseBatchNumberToSalesTable(purchLine);
}
}
}
}
That's it. It worked fine.
@Rahul
No comments:
Post a Comment