Using X++ code get your Intercompany CustAccount
Ever wonder if there is an easy way to find out what customer account a sales company has at the production company?
This might not be an easy way, but it is one way to do it:
remark by Jimmy on May 26th 2011
static void Jimmy_IntercompanyCustAccount(Args _args)
{
VendTable vendTable;
AifEndpointId endpointId;
AifEndpoint toEndpoint,meEndPoint;
AifEndPointConstraint endPointConstraint;
;
// Intercompany Vendor = 60001.
vendTable = VendTable::find("60001");//execute in qvsHK account
// Get Vendor endpointId.
endpointId = vendTable.interCompanyEndpointId();
// Get the endpoint.
toEndpoint = AifEndPoint::find(endpointId);
// Change to endPoint company.
changecompany(toEndpoint.InterCompanyCompanyId)
{
// Get your endpoint in Parent company.
meEndPoint = AifEndpoint::findInterCompany(toEndpoint.dataAreaId);
// Find customer constraint.
endPointConstraint = AifEndPointConstraint::find(meEndPoint.EndpointId,AifConstraintType::Customer);
}
// ConstraintId = Your customer account.
info(endPointConstraint.ConstraintId);//QVSHK
}