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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Global address book

(0) ShareShare
ReportReport
Posted on by

1. Delete un-matched location
    while select forupdate inventLocationLogisticsLocation
        where inventLocationLogisticsLocation.InventLocation == sInventLocation.RecId
    notexists join dirPartyLocation
        where dirPartyLocation.Location == inventLocationLogisticsLocation.Location
           && dirPartyLocation.Party == this.OMOperatingUnitID
    {
        deletePostalAddress = LogisticsPostalAddress::findByLocation(inventLocationLogisticsLocation.Location, true);
        if (deletePostalAddress.RecId)
            if (deletePostalAddress.aosValidateDelete())
                deletePostalAddress.delete();
        inventLocationLogisticsLocation.delete();
    }
 2. Update matched location
    while select forUpdate inventLocationLogisticsLocation
        where inventLocationLogisticsLocation.InventLocation == sInventLocation.RecId
    join  dirPartyLocation
        where dirPartyLocation.Location == inventLocationLogisticsLocation.Location
            && dirPartyLocation.Party == this.OMOperatingUnitID
    join logisticsPostalAddress
        where logisticsPostalAddress.Location == dirPartyLocation.Location
    {
        rolesCon = _rolesMap.lookup(dirPartyLocation.Location);
        inventLocationLogisticsLocation.InventLocation = sInventLocation.RecId;
        inventLocationLogisticsLocation.Location = dirPartyLocation.Location;
        inventLocationLogisticsLocation.IsPrimary = dirPartyLocation.IsPrimary;
        inventLocationLogisticsLocation.IsPrivate = logisticsPostalAddress.IsPrivate;
        inventLocationLogisticsLocation.addEntityLocation(rolesCon, true);
        inventLocationLogisticsLocation.update();
    }
 3. Insert new location
    while select  dirPartyLocation
        where dirPartyLocation.Party == this.OMOperatingUnitID
    notExists join inventLocationLogisticsLocation
        where inventLocationLogisticsLocation.InventLocation == sInventLocation.RecId
            && inventLocationLogisticsLocation.Location == dirPartyLocation.Location
    notexists join  logisticsPostalAddress
        where logisticsPostalAddress.Location == dirPartyLocation.Location
    {
        rolesCon = _rolesMap.lookup(dirPartyLocation.Location);
        //Create new location
        newLogisticsLocation = LogisticsLocation::create(LogisticsLocation::find(dirPartyLocation.Location).Description);

 

        //Create address
        newPostalAddress.clear();
        newPostalAddress.data(logisticsPostalAddress::findByLocation(dirPartyLocation.Location));
        newPostalAddress.Location = newLogisticsLocation.RecId;
        newPostalAddress.insert();
       //Create mapping
        newInventLocationLogisticsLocation.clear();
        newInventLocationLogisticsLocation.InventLocation = sInventLocation.RecId;
        newInventLocationLogisticsLocation.Location = newLogisticsLocation.RecId;
        newInventLocationLogisticsLocation.IsPrimary = dirPartyLocation.IsPrimary;
        newInventLocationLogisticsLocation.IsPrivate = logisticsPostalAddress.IsPrivate;
        newInventLocationLogisticsLocation.insert();
        newInventLocationLogisticsLocation.addEntityLocation(rolesCon, true);
    }
    ttsCommit;

I am using the joins above for inserting ,deleting and updating the address in retain channel and in the warehouse.

It is working fine for me in DEV and in QA but  when I ran the same piece code in PROD it is killing the performance and it is taking almost 6-7 mins to update/insert/delete.

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    303,390 Super User 2026 Season 1 on at

    Hi mahiims18,

    Did you test in DEV and QA with the same data and security roles? How many records are involved? If so, you have to start monitoring what might be wrong. You can check for fragmented or missing indexes. You can also use the Trace parser and check which part of the execution is causing the delays.

  • Suggested answer
    greengrimms Profile Picture
    1,400 on at

    Hi,

    As previously suggested, use trace parser in order to find out where the query is having problems.

    I suggest taking the trace on prod (or any other environment where you can replicate this), downloading it in your dev vm and then importing it there to the Dynamics 365 Trace Parser tool. Then you can take the trace, and sort the SQL queries by execution time and see which one is causing trouble. After that, you can take the query and run the Execution plan in SQL in a lower tier environment.

    Also if I may suggest, get a copy of the prod database to a lower tier environment for easier testing/debugging.

    Good luck and feel free to reach out.

  • Suggested answer
    Rachit Profile Picture
    4,015 User Group Leader on at

    You can create it as a batch task and use multithreading to improve the performance.

    microsoft-dynamics-ax-erp.blogspot.com/.../batch-parallelism-in-ax-part-i.html

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans