Get Customer Account Intercompany - Microsoft Dynamics 365 Vietnam

Microsoft Dynamics 365 Vietnam

Song Nghia - Microsoft Dynamics 365 Vietnam

Breaking

Thursday, June 25, 2020

Get Customer Account Intercompany

Get Customer Account Intercompany
Song Nghia - Technical Consultant



private CustAccount getCustAccountInterCompany(RetailStoreTable retailStoreTable)
    {
        CustAccount  custAccount;
        InterCompanyTradingPartner interCompanyTradingPartner;
        RecId tradingPartnerVendRecId, tradingPartnerCustRecId;
        CustTable  custTbl;
        changecompany(retailStoreTable.inventLocationDataAreaId)
        {
            VendTable vendTable =  VendTable::find(retailStoreTable.LAW_DefaultVendor);
            RecId partyId = vendTable.Party;
            tradingPartnerVendRecId = InterCompanyTradingPartner::findVendor(partyId,retailStoreTable.inventLocationDataAreaId).RecId;
        }

        select interCompanyTradingPartner
            where interCompanyTradingPartner.RecId == tradingPartnerVendRecId;

        tradingPartnerCustRecId = InterCompanyTradingRelation::getRelatedTradingPartner(interCompanyTradingPartner).RecId;

        custAccount= InterCompanyTradingRelation::getRelatedTradingPartner(interCompanyTradingPartner).custTable().AccountNum;
        
        return custAccount;
    }