Creating Vendors through X++ in AX 2012- PART VI

Creating Vendors through X++ in AX 2012- PART VI


--Create communication details--

public void createCommAddress(VendorRequestCreate          _vendorRequestCreate)
{
    VendorRequestCommunication       vendorRequestCommunication;
    ;
select Phone1, Phone2, Email, Fax from vendorRequestCommunication 
where vendorRequestCommunication.WI_VendorRequestCreate == _vendorRequestCreate.RecId;
//Phone 1
if(vendorRequestCommunication.Phone1 != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Phone 1';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Phone1;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Phone;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
//Phone 2
if(vendorRequestCommunication.Phone2 != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Phone 2';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Phone2;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Phone;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::No;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
//Email
if(vendorRequestCommunication.Email != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Email';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Email;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Email;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
//Fax
if(vendorRequestCommunication.Fax != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Fax';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Fax;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Fax;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
}


Check below posts for more details....




-Harry

Comments

Popular posts from this blog

Connecting to Databases through X++ PART -I

X++ code for document attachment

Multiple Tables In Query