Business requirement: add fields for intercompany synchronization
If you need to synch additional sales line fields upon activation of the intercompany chain, some code modifications have to been executed. In this example the Customer Reference on the salesline needed to be synchronized.(field CustomerRef). End users had to be able to input a different customer reference line by line, not one general customer reference for the sales order as a whole.
Solution: X++ modifications
First of all the field CustomerRef should be set to visible on the salesline, so end users can modify it. The field is already available in the AOT on the SalesLine table, it is only not visible in the form.
Next, modify the method interCompanyUpdateNow on the PurchLine table: add some code for the new field to be synchronized.
...
|| this.orig().ReturnDispositionCodeId
!= this.ReturnDispositionCodeId
|| this.orig().ReturnStatus
!= this.ReturnStatus
|| this.orig().MatchingAgreementLine
!= this.MatchingAgreementLine
// BEGIN
|| this.orig().CustomerRef
!= this.CustomerRef
// END
)
{
ok = true;
}
...
Add a new parm method to the class AxPurchLine for the new field to be synchronized.
public CustRefLine parmCustRefLine(CustRefLine
_custRefLine = '')
{
if (!prmisDefault(_custRefLine))
{
this.setField(fieldNum(PurchLine, CustomerRef),
_custRefLine);
}
return purchLine.CustomerRef;
}
Add a new parm method to the class AxSalesLine for the new field to be synchronized.
public CustRefLine parmCustRefLine(CustRefLine
_custRefLine = '')
{
if (!prmisDefault(_custRefLine))
{
this.setField(fieldNum(SalesLine, CustomerRef),
_custRefLine);
}
return salesLine.CustomerRef;
}
Modify the interCompanyMirror method of class PurchLineType so the new field gets synchronized upon creation of changing the purchline.
...
// BEGIN
if (create || purchLine.fieldChanged(fieldNum(PurchLine,
CustomerRef)))
axSalesLine.aduParmCustRefLine(purchLine.CustomerRef);
// END
...
Modify the syncPurchLine method of class SalesLineType so the new field gets synchronized upon creation of changing the salesline.
...
// BEGIN
if (create
|| _salesLine.fieldChanged(fieldNum(SalesLine,
CustomerRef)))
axPurchLine.aduParmCustRefLine(_salesLine.CustomerRef);
// END
...
Hello!
In your example you use a field that already exists in the purchTable (CustomerRef)
If you want to inherit a field from the salesTable (over a purchTable) to another salesTable that doesn't exist in the purchTable, do you have to create that field in the purchTable?
Yes you have.
Very helpful!!! thankxs
Post a Comment