Country Region ID Vendor or Customer

static void FindPrimaryAddress(Args _args)
{
    ProjInvoiceItem             projInvoiceItem;
    VendInvoiceTrans            vendInvoiceTrans;
    ProjTable                   projTable;
    LogisticsPostalAddressView  logisticsPostalAddressView;
    DirPartyLocation            dirPartyLocation;
    RefRecId                    party,location;
    VendTrans                   vendTrans;
    VendTable                   vendTable;



    //select ProjId from projInvoiceItem
        //where projInvoiceItem.RecId == 5637145326;

    select Name,CustAccount from projTable
        join ProjId from projInvoiceItem
        where projInvoiceItem.RecId == 5637145326
            && projTable.ProjId == projInvoiceItem.ProjId;

    info(strFmt('%1, %2 , %3,%4', projTable.CustAccount ,projTable.Name,projTable.custName(),projInvoiceItem.ProjId ));
    //party = CustTable::find(projTable.CustAccount).Party;
    //location = DirPartyLocation::findPrimaryPartyLocation(party).Location;
    select countryregionid from logisticsPostalAddressView
        where logisticsPostalAddressView.Location == DirPartyLocation::findPrimaryPartyLocation(CustTable::find(projTable.CustAccount).Party).Location;
    info(strFmt('%1', logisticsPostalAddressView.CountryRegionId ));

    //select AccountNum from vendTrans
        //where vendTrans.Voucher == 'DXVIN-00109';

    //select AccountNum from vendTrans
        //join Party,VATNum from vendTable
        //join countryregionid from logisticsPostalAddressView
        //where vendTrans.Voucher == 'DXVIN-00109'
            //&& vendTable.AccountNum == vendTrans.AccountNum
            //&& logisticsPostalAddressView.Location == DirPartyLocation::findPrimaryPartyLocation(vendTable.Party).Location;

    select countryregionid from logisticsPostalAddressView
        where logisticsPostalAddressView.Location == DirPartyLocation::findPrimaryPartyLocation(vendTable.Party).Location;

    select AccountNum from vendTrans
        join Party,VATNum from vendTable
        where vendTrans.Voucher == 'DXVIN-00109'
            && vendTable.AccountNum == vendTrans.AccountNum;

    select countryregionid from logisticsPostalAddressView
        where logisticsPostalAddressView.Location == DirPartyLocation::findPrimaryPartyLocation(VendTable::find(vendTrans.AccountNum).Party).Location;

    info(strFmt('%1, %2 , %3,%4,%5', vendTrans.AccountNum,vendTrans.vendTableName(),vendTable.Party,
                vendTable.VATNum,logisticsPostalAddressView.CountryRegionId));
}

Comments

Popular posts from this blog

Create RFQ through X++

Base enum values in Dynamics 365

Project Id through X++ code