web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Importing Vendor Contact Information

(0) ShareShare
ReportReport
Posted on by 2,459

I would like to update all my vendor's contact information, and create new entries.

If i use DIEF/DIXF, i find that it overwrites the information in the system, where i have empty/blank fields. Is there a way to have DIEF only recognise the columns that are in the import file? and not overwrite all the other columns with 'blank'..

2017_2D00_09_2D00_19_5F00_1326.png

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    B K Sharma Profile Picture
    737 on at

    Hi James,

    I have used below code for Customer address creation for my business, you can modify it as per you requirement for vendor contact information update.

    Let me know if you have any query

    public str 1000 FinalCustomerAddressCreation(LogisticsAddressCountryRegionId   _CountryRegionId, Description                       _AddressDescription,

                                                       LogisticsAddressZipCodeId         _DPCode,          CustAccount                       _CustAcount,

                                                       LogisticsAddressStreet            _AddressStreet,   LogisticsElectronicAddressLocator _Phone1 = "",

                                                       LogisticsAddressPostBox           _PostBox = "",    LogisticsElectronicAddressLocator _Phone2 = "",

                                                       TaxRegistrationNumber_IN          _GSTINRegNumber = "")

    {

       LogisticsLocation           LogisticsLocation,_LogisticsLocation;

       LogisticsPostalAddress      LogisticsPostalAddress;

       DirPartyLocation            DirPartyLocation;

       DirPartyLocationRole        DirPartyLocationRole;

       LogisticsElectronicAddress  LogisticsElectronicAddress;

       LogisticsLocationRole       LogisticsLocationRole;

       LogisticsAddressZipCode     LogisticsAddressZipCode;

       NumberSeq                   num;

       LogisticsLocationId         _LocationId;

       LogisticsLocationRecId      _recid;

       TaxInformation_IN           _taxInformation;

       TaxRegistrationNumbers_IN   _taxRegistration;

       int _line;

       ;

       try

       {

           _line = infologLine();

           if(!LogisticsAddressCountryRegion::find(_CountryRegionId))

           {

               throw error("Country region not found");

           }

           else if(!_AddressDescription)

           {

               throw error("Address description is mandatory");

           }

           else if (!LogisticsAddressZipCode::find(_DPCode) || LogisticsAddressZipCode::find(_DPCode).S3_DPCode == NoYes::No)

           {

               throw error("Delivery point not found");

           }

           else if(!CustTable::find(_CustAcount))

           {

               throw error("Customer not found");

           }

           else if(!_AddressStreet)

           {

               throw error("Address Street is mandatory");

           }

           ttsBegin;

           _LocationId = LogisticsLocation::getNewLocationId();

           //Create logistics location

           LogisticsLocation.LocationId  = _LocationId;

           LogisticsLocation.Description = _AddressDescription;

           LogisticsLocation.IsPostalAddress = NoYes::Yes;

           LogisticsLocation.insert();

           //insert location to party location

           DirPartyLocation.Location = LogisticsLocation.RecId;

           DirPartyLocation.IsLocationOwner = NoYes::Yes;

           DirPartyLocation.IsPrimary = NoYes::No;

           DirPartyLocation.IsPostalAddress = NoYes::Yes;

           DirPartyLocation.Party = CustTable::find(_CustAcount).Party;

           DirPartyLocation.insert();

           //insert into role like Delivery/Invoice

           DirPartyLocationRole.LocationRole = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery).RecId;

           DirPartyLocationRole.PartyLocation = DirPartyLocation.RecId;

           DirPartyLocationRole.insert();

           //insert into logistics postal address

           LogisticsPostalAddress.CountryRegionId = _CountryRegionId;

           LogisticsPostalAddress.ZipCode = _DPCode;

           LogisticsPostalAddress.Street  = _AddressStreet;

           LogisticsPostalAddress.PostBox = _PostBox;

           LogisticsAddressZipCode = LogisticsAddressZipCode::find(_DPCode);

           LogisticsPostalAddress.city            = LogisticsAddressZipCode.City;//Tehsil

           LogisticsPostalAddress.CityRecId       = LogisticsAddressZipCode.CityRecId;

           LogisticsPostalAddress.DistrictName    = LogisticsAddressZipCode.DistrictName;//city

           LogisticsPostalAddress.District        = LogisticsAddressZipCode.District;//city recid

           LogisticsPostalAddress.County          = LogisticsAddressZipCode.County;

           LogisticsPostalAddress.State           = LogisticsAddressZipCode.State;

           LogisticsPostalAddress.Address         = LogisticsPostalAddress.Street +", "+ LogisticsAddressZipCode.DistrictName +", "+ LogisticsAddressZipCode.City + ", " + LogisticsAddressZipCode.County +", "+ LogisticsAddressZipCode.State + ", " + LogisticsAddressZipCode.ZipCode + ", India";

           LogisticsPostalAddress.Location        = LogisticsLocation.RecId;

           LogisticsPostalAddress.ZipCodeRecId    = LogisticsAddressZipCode.RecId;//Added by BK as on 08.04.2016

           LogisticsPostalAddress.insert();

           if(_GSTINRegNumber != "")

           {

               _taxRegistration = TaxRegistrationNumbers_IN::findByNaturalKey(TaxRegistrationType_IN::Customers, TaxType_IN::GST, _GSTINRegNumber);

               if(_taxRegistration.RecId == 0)

               {

                   //Create Tax Registration for GSTN number

                   _taxRegistration.TaxType            = TaxType_IN::GST;

                   _taxRegistration.RegistrationType   = TaxRegistrationType_IN::Customers;

                   _taxRegistration.RegistrationNumber = _GSTINRegNumber;

                   _taxRegistration.Name               = _AddressDescription;

                   _taxRegistration.insert();

               }

               //Create Tax information for this location

               _taxInformation.RegistrationLocation = LogisticsLocation.RecId;

               _taxInformation.Name                 = _AddressDescription;

               _taxInformation.IsPrimary            = NoYes::Yes;

               _taxInformation.GSTIN                = _taxRegistration.RecId;

               _taxInformation.insert();

           }

           ////Phon number 1 insertion

           if(_Phone1 || _Phone2)

           {

               _recid  = LogisticsLocation::create('', false, logisticsLocation.RecId).RecId;

           }

           if(_Phone1)

           {

               logisticsElectronicAddress.Location = _recid;

               LogisticsElectronicAddress.Description = "Celluler Phone1";

               LogisticsElectronicAddress.IsMobilePhone = NoYes::Yes;

               LogisticsElectronicAddress.Type          = LogisticsElectronicAddressMethodType::Phone;

               LogisticsElectronicAddress.Locator       = _phone1;

               LogisticsElectronicAddress.insert();

           }

           //Second phone number

           if(_Phone2)

           {

               logisticsElectronicAddress.Location = _recid;

               LogisticsElectronicAddress.Description = "Celluler Phone2";

               LogisticsElectronicAddress.IsMobilePhone = NoYes::Yes;

               LogisticsElectronicAddress.Type          = LogisticsElectronicAddressMethodType::Phone;

               LogisticsElectronicAddress.Locator       = _phone2;

               LogisticsElectronicAddress.insert();

           }

           ttsCommit;

           return "True$" + _LocationId;

       }

       catch (Exception::Error)

       {

           return Utilities.GetInfologInOneLine(_line);

       }

    }

    Thanks

  • SU-22040800-0 Profile Picture
    2,459 on at

    Thanks B K

    What would the import file look like? comma separated..? which columns?

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    You can use the following job to update vendor contact details. It updates vendor contact details, only if there are blank. You can comment that condition if you want and update the job accordingly. Input is a CSV file with a comma delimiter(as shown below). Please try with a single record and let me know if any changes are required. 

    VendorContact.jpg

    static void uploadVendorDetails(Args _args)
    {
        CommaTextIO                 csvFile;
        container                   readCon;
        Dialog                      dialog;
        DialogField                 dfFileName;
        FileName                    fileName;
        VendTable                   vendTable;
        DirParty                    dirParty;
        DirPartyRecId               partyRecId;
        AccountNum                  accountNum;
        
        DirPartyContactInfoView     contactView;
        
        #File
        
        dialog = new Dialog("Pick the file");
        dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
        dialog.filenameLookupFilter(['csv','*.csv']);
        
        if (dialog.run())
        {
            csvFile = new CommaTextIo(dfFileName.value(), 'r');
            csvFile.inFieldDelimiter(',');
            readCon = csvFile.read();
            
            while(csvFile.status() == IO_Status::OK)
            {
                readCon = csvFile.read();
    
                if(readCon)
                {
                    accountNum = conPeek(readCon,1);
    
                    vendTable = vendTable::find(conPeek(readCon,1));
                    partyRecId = vendTable.Party;                
                    DirParty = DirParty::constructFromPartyRecId(partyRecId); 
                    
                    select contactView
                        where contactView.Party == vendTable.Party
                        && contactView.Type == LogisticsElectronicAddressMethodType::Phone; 
                    
                    // Phone description and Phone number
                    if ((contactView.RecId == 0) && (conPeek(readCon,2) != "")) // Please comment this condition, if not required
                    {
                        contactView.LocationName = "Phone Number"; // Phone description
                        contactView.Locator      = strLRTrim(conPeek(readCon,3)); // Phone Number
                        contactView.Type         = LogisticsElectronicAddressMethodType::Phone;
                        contactView.Party        = partyRecId;
                        contactView.IsPrimary    = NoYes::Yes;
                        dirParty.createOrUpdateContactInfo(contactView);
                    }
                    
                    select contactView
                        where contactView.Party == vendTable.Party
                        && contactView.Type == LogisticsElectronicAddressMethodType::Email; 
                    
                    // Email name and emailId
                    if ((contactView.RecId == 0) && (conPeek(readCon,4) != "")) // Please comment this condition, if not required
                    {
                        contactView.LocationName = "Email"; // Email description
                        contactView.Locator      = strLRTrim(conPeek(readCon, 5)); // EmailId
                        contactView.Type         = LogisticsElectronicAddressMethodType::Email;
                        contactView.Party        = partyRecId;
                        contactView.IsPrimary    = NoYes::Yes;
                        dirParty.createOrUpdateContactInfo(contactView);
                    }
                    
                    select contactView
                        where contactView.Party == vendTable.Party
                        && contactView.Type == LogisticsElectronicAddressMethodType::URL; 
                    
                    // URL description and URL 
                    if ((contactView.RecId == 0) && (conPeek(readCon,6) != "")) // Please comment this condition, if not required
                    {
                        contactView.LocationName = "URL"; // URl Description
                        contactView.Locator      = strLRTrim(conPeek(readCon,7)); // URL
                        contactView.Type         = LogisticsElectronicAddressMethodType::URL;
                        contactView.Party        = partyRecId;
                        contactView.IsPrimary    = NoYes::Yes;
                        dirParty.createOrUpdateContactInfo(contactView);
                    }
                    
                    select contactView
                        where contactView.Party == vendTable.Party
                        && contactView.Type == LogisticsElectronicAddressMethodType::Fax; 
                    
                    // Fax description and Fax number 
                    if ((contactView.RecId == 0) && (conPeek(readCon,8) != "")) // Please comment this condition, if not required
                    {
                        contactView.LocationName = "Fax"; // Fax Description
                        contactView.Locator      = strLRTrim(conPeek(readCon,9)); // Fax description
                        contactView.Type         = LogisticsElectronicAddressMethodType::Fax;
                        contactView.Party        = partyRecId;
                        contactView.IsPrimary    = NoYes::Yes;
                        dirParty.createOrUpdateContactInfo(contactView);
                    }
                }
            }
        }
    }


  • Suggested answer
    Ajit Profile Picture
    8,755 on at

    If you check the 'GenerateElectronicLocation' method of class 'DMFVendorEntityClass', it is including that column if that has value in it. Please make sure those columns doesn't have space and all. You can review entity class.

  • SU-22040800-0 Profile Picture
    2,459 on at

    This works perfectly for new records (no updates) - thanks Chaitanya!

    I added some script to get the LocationName from strLRTrim(conPeek(readCon,XX));  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans