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

How to update the primary key cross company?

(0) ShareShare
ReportReport
Posted on by 162

I have a data discrepancy, where I need to rename the vendor ids having same party number across all the legal entities to specific number. Anyway to achieve it? Q

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Harshal, You can use below sql script in SQL server to find how many records you need to change and based on number of records you can create the logic.

    select PARTY from VendTable
    join DIRPARTYTABLE
    on VENDTABLE.PARTY = DIRPARTYTABLE.RECID
    group by VendTable.PARTY
    Having count(VendTable.PARTY) > 1

    For x , you have to use crosscompany keyword to iterate all records, check these articles

    http://allaboutax.blogspot.com/2019/05/duplicate-records-in-dynamics-365.html

    https://www.d365stuff.co/update_recordset-but-cross-company/ (won't recommend to skip standard validations)

    As discussed, primary key can be updated using below article

    subscription.packtpub.com/.../renaming-the-primary-key

  • Harshal Jain Profile Picture
    162 on at

    Hi Mohit,

    Thanks for the reply. I was already using these things and was able to resolve my problem.

  • Anton Venter Profile Picture
    20,635 Super User 2026 Season 1 on at

    Good to hear it was solved. Could you verify the answer for future users? Thanks.

  • Harshal Jain Profile Picture
    162 on at

    Hi ,

    I used this piece of code -

      while select  crosscompany : conCompanies
                * from vendTable
                 join PartyNumber from  partyTable order by PartyNumber
                      where   partyTable.RECID == vendTable.PARTY && (partyTable.PartyNumber == '000000126')
    
            {
    
    
    
                if(partyNum == '' || partyNum == partyTable.PartyNumber)
                {
                    vendTable.AccountNum = vendAccount;
                    vendTable.renamePrimaryKey();
                    partyNum = partyTable.PartyNumber;
    
                }
                }

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... 527 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 473

#3
Adis Profile Picture

Adis 284 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans