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, ...
Answered

BULK UPDATE OF SALES UNIT and SALES District for customer

(1) ShareShare
ReportReport
Posted on by 275
Hi Everyone!
I am seeking assistance to perform a bulk update of the sales district and sales unit for customers within the CustGroup 'XYZ'(Suppose) using SQL. The update should be executed under the following conditions: the CustGroup must be 'XYZ', the customer delivery address should be primary, and based on the delivery address state, the customer's sales unit and district should be updated accordingly.
I have attempted to fetch the necessary data but am encountering issues with the joins and possibly the table selection. The query I have constructed is as follows:
[SELECT CT.AccountNum, CT.CUSTGROUP, CT.SALESDISTRICTID, CT.ISALESUNITID, DPL.ISPRIMARY
FROM CustTable CT
JOIN DIRPARTYTABLE DPT ON CT.PARTY = DPT.RECID
JOIN DIRPARTYLOCATION DPL ON DPT.RECID = DPL.PARTY
JOIN LOGISTICSADDRESSCOUNTRYREGION LACR ON CT.PARTYCOUNTRY = LACR.COUNTRYREGIONID
INNER JOIN LOGISTICSPOSTALADDRESS LPA ON LACR.COUNTRYREGIONID = LPA.COUNTRYREGIONID
INNER JOIN LogisticsAddressDistrict LAD ON LPA.DISTRICTNAME = LAD.NAME AND LPA.DISTRICT = LAD.RECID
WHERE CT.CustGroup = 'WTD'
AND DPL.ISPRIMARY = 1
]
The update will be carried out in SQL. The relationships I have established were derived from my AX2012 system, and I am attempting to perform the bulk update accordingly. Thank you in advance for your help, and please feel free to request any additional details you may require.
  • André Arnaud de Calavon Profile Picture
    307,786 Super User 2026 Season 2 on at
    Hi Ayushaman,
     
    Can you tell us what issues you are encountering, do you get an error, too many, or not all relevant records in the result set? What exact version of AX 2012 are you using?
  • Ayushaman Profile Picture
    275 on at
    Hi Andre,
     
    When i am joining LOGISTICSADDRESSCOUNTRYREGION ,LOGISTICSPOSTALADDRESS ,LogisticsAddressDistrict  I am not getting any data  zero records joining till DIRPARTYLOCATION  is working fine. I am getting desired record but for updating I need primary delivery address state of customers to be fetched based on that I will update SalesUnit and Sales District .The version I am using is AX2012 R3.the query I am running in SQL server but the joining relation I retrieved it from AX itself. Basically we need to bulk update from backend based on the condition I earlier told you .

    Thanks,
    Ayushaman 
  • Verified answer
    André Arnaud de Calavon Profile Picture
    307,786 Super User 2026 Season 2 on at
    Hi Ayushaman,

    I think you will need to change your query. A country is not used to find an address in the AX application.

    The DirPartyLocation.Location field has a relation to the table LogisticsLocation on the RecId field. This table has a field to indicate if a location is a postal address. If so, you can use the Location field or RecId from the LogisticsLocation table to find a record in the table LogisticsPostalAddress.
     
     
  • Ayushaman Profile Picture
    275 on at
    Thanks a bunch Andre!! I got the result as expected.
  • André Arnaud de Calavon Profile Picture
    307,786 Super User 2026 Season 2 on at
    Hi Ayushaman,

    If your question has been answered, would you mind marking the reply or replies that helped you? The status of the question will then be set to Answered which is helpful for other persons if they have the same question in future.
  • Suggested answer
    Ayushaman Profile Picture
    275 on at
    Joining 
    ​​​​​​​CustTable CT WITH (NOLOCK)
        JOIN DIRPARTYTABLE DPT WITH (NOLOCK) ON CT.PARTY = DPT.RECID
        JOIN DIRPARTYLOCATION DPL WITH (NOLOCK) ON DPT.RECID = DPL.PARTY
        JOIN LOGISTICSLOCATION LL WITH (NOLOCK) ON LL.RECID = DPL.LOCATION 
        JOIN LOGISTICSPOSTALADDRESS LPA WITH (NOLOCK) ON LPA.LOCATION = LL.RECID
     
    Thanks 
    Ayushaman 
  • Suggested answer
    Ayushaman Profile Picture
    275 on at
    Hi Andre, 
    Apologies for the delayed response I already tried to mark your reply as answered but it's not allowing me when I click on does this answer you question checkbox. If you know any other way around kindly let me know and I will mark it right away .
     
    Thanks 
    Ayushaman 
  • André Arnaud de Calavon Profile Picture
    307,786 Super User 2026 Season 2 on at
    Thanks for the update, Ayushaman. I was able to mark the reply. For the next question please try again marking a reply. There was an issue in the past, but I don't know if there is still a small error related to marking replies for some users.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 363 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 188

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans