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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Import FA locations with Addresses

(0) ShareShare
ReportReport
Posted on by 830

Hello,

how to import Fixed assets locations with addresses through DIEF?

Regards,

David

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    try to use asset entity ,check this blog for more details

    community.dynamics.com/.../import-assets-using-data-import-framework-ax-2012-r3

  • David Tailor Profile Picture
    830 on at

    Hi Mahmoud,

    the Asset entity did not have address of location.

    we can use the link you mentioned to import assets with locations.

    what i need in addition is to import address of FA location.

    Regards,

    David

  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    Try to publish address via excel add-in

    atinkerersnotebook.com/.../using-the-dynamics-ax-excel-add-in

  • David Tailor Profile Picture
    830 on at

    it didn't work with Excel Add-in. I coudn't add a new address.

    what i need, FA locations can be added easily through DIEF.

    I need a way to import address for every FA location.

    Regards,

    David

  • Sangram Shinde Profile Picture
    2,114 on at

    Hi David,

    Which entity are you using to import it?

    Thanks,

    Sangram

  • David Tailor Profile Picture
    830 on at

    Hi Sangram,

    I used FA asset location entity, it has location, location id and name fields.

    Regards,

    David

  • Suggested answer
    Sangram Shinde Profile Picture
    2,114 on at

    Hi David,

    I can't see this entity in my box, you have to write a new method to add address code along with locations in your entity class.

    Meanwhile you can use below code to import your data, this code will import locations with it's address, you can add additional address fields as required. You have to use a CSV file with header to import this. please prepare your CSV file as per the sequence in below code, or change the code as per your file sequence. Please see if this helps.

    static void SSFALocationAddressImport(Args _args)
    {
        Dialog                              dialog;
        DialogField                         dfFileName;
        int                                 noOfRecs = 0;
        CommaIO                             csvFile;
        container                           fileInCon,checkcon;
        counter                             icount,inserted,updated;
        FileName                            fileName;
    
        AssetLocation                       assetLocation;
        AssetLocationId                     assetLocationId;
        AssetLocationName                   assetLocationName;
        LogisticsPostalAddress              postalAddress;
        LogisticsLocation                   location;
        LogisticsAddressCity                city;
        LogisticsAddressCountyId            county;
        LogisticsAddressZipCodeId           zipcode;
        LogisticsAddressStateId             state;
        LogisticsAddressCountryRegionId     country;
        LogisticsAddressStreet              streetname;
        LogisticsAddressCountryRegion       logisticsAddressCountryRegion;
        LogisticsAddressState               logisticsAddressState;
        LogisticsAddressZipCode             logisticsAddressZipCode;
        LogisticsAddressCounty              logisticsAddressCounty;
        LogisticsAddresssCity               logisticsAddresssCity;
        Description                         addressName;
    
        ;
    
        inserted    = 0;
        dialog      = new Dialog("Pick the file");
        dfFileName  = dialog.addField(extendedTypeStr(FileNameOpen));
        dialog.filenameLookupFilter(["CSV ","*.csv"]);
    
        if (dialog.run())
        {
            filename =  dfFileName.value();
        }
    
        csvFile     = new CommaIO(filename, 'r');
    
        if (csvFile)
        {
            while (csvFile.status() == IO_Status::OK)
            {
                try
                {
                    fileInCon = csvFile.read();
                    icount++;
    
                    if (fileInCon && icount>1)
                    {
                        assetLocationId         =  conPeek(fileInCon,1);
                        assetLocationName       =  conPeek(fileInCon,2);
                        addressName             =  conPeek(fileInCon,3);
                        city                    =  conPeek(fileInCon,4);
                        state                   =  conPeek(fileInCon,5);
                        country                 =  conPeek(fileInCon,6);
                        zipcode                 =  conPeek(fileInCon,7);
                        streetname              =  conPeek(fileInCon,8);
                        
                        if (state)
                        {
                            logisticsAddressState=LogisticsAddressState::find(country,state);
                            if(!logisticsAddressState)
                            {
                                info(strFmt("State %1 is not present",state));
                                continue;
                            }
                            
                        }                  
                        if (city)
                        {
                            logisticsAddresssCity=LogisticsAddresssCity::findCityState(city,state);    
                            if(!logisticsAddresssCity)
                            {
                                info(strFmt("City %1 is not present",city));
                                continue;
                                
                            }
                            
                        }
                        if (zipcode)
                        {
                            logisticsAddressZipCode=LogisticsAddressZipCode::findZipCodeCity(zipcode,city);
                            if(logisticsAddressZipCode)
                            {
                                 info(strFmt("ZipCode %1 is not present",zipcode));   
                                 continue;
                            }
                        }
                        
                        location.clear();
                        location.Description = addressName;
                        location.insert();  
                        
                        postalAddress.Location           =   location.RecId;
                        postalAddress.CountryRegionId    =   country;
                        postalAddress.Street             =   streetname;
                        postalAddress.City               =   city;                                              
                        postalAddress.State              =   state;
                        postalAddress.ZipCode            =   zipcode;
                        postalAddress.LogisticsPostalAddressMap::formatAddress();
                        postalAddress.insert();
                        assetLocation =  AssetLocation::find(assetLocationId,true); 
                        
                        if (assetLocation)
                        {
                            ttsbegin;
                            assetLocation.LogisticsLocation         = location.RecId;
                            assetLocation.Location                  = assetLocationId;
                            assetLocation.Name                      = assetLocationName;
                            assetLocation.update();
                            updated++;
                            ttsCommit;
    
                        }
    
                        else
                        {
                            assetLocation.clear();
                            assetLocation.LogisticsLocation          = location.RecId;
                            assetLocation.Location                   = assetLocationId;
                            assetLocation.Name                       = assetLocationName;                                          
                            assetLocation.insert();
                            inserted++;
    
                        } 
                    }
                }//try
                catch
                {
                    info(strFmt("Error at line %1",icount));
                }
            }//while
        }//if csv
            info(strfmt("%1 records inserted, %2 records updated",inserted,updated));
    
    }//final


  • Verified answer
    Sangram Shinde Profile Picture
    2,114 on at

    Hi David,

    Please replace below line in code.


    if(logisticsAddressZipCode) to if(!logisticsAddressZipCode)

    Thanks,

    Sangram

    
    
                          
  • Suggested answer
    ZvikaR Profile Picture
    184 on at

    FYI D365 allows you to upload FA location and address through the Excel integration in a much quicker and simpler way

  • David Tailor Profile Picture
    830 on at

    Hi Zvika,

    thank you for your reply,

    is this true for AX 2012 R3  as well?

    Regards,

    David

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans