Skip to main content
Post a question

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Copy Customer Account from one LE to Another

Like (2) ShareShare
ReportReport
Posted on 29 Jan 2025 21:56:09 by 20
Hello,
 
We have just brought on another legal entity and we want to be able to copy new customer accounts from LE to the new LE as they are created. 
 
We use dual write, so we can not use cross company data sharing. We did turn off dual write and we did an initial push from one LE to the other using CCDS. 
We are using the Data Management copy once per week, but because it takes over 7 hours to run we can not run it more often.
 
What we'd like to do is insert or update the customer account at the time it is created or updated in the primary LE. 
I have been looking at an extension class on the CustTable, but it does not seem that we can update the dataareaid through code.
 
Does anyone have any input on how this might be able to accomplished?
 
Thank you.
 
 
 
 
Categories:
  • Waed Ayyad Profile Picture
    Waed Ayyad 7,323 Super User 2025 Season 1 on 31 Jan 2025 at 15:41:56
    Copy Customer Account from one LE to Another

    Hi, 

    Is your issue resolved? If yes, mark the answers that helped you as verified. 

    Thanks,

    Waed Ayyad

  • Verified answer
    ET-29012149-0 Profile Picture
    ET-29012149-0 20 on 31 Jan 2025 at 12:38:48
    Copy Customer Account from one LE to Another
     
    I appreciate your response, but I do not understand what you mean.
    I'm sorry.
  • Suggested answer
    BillurSamdancioglu Profile Picture
    BillurSamdancioglu 16,755 Most Valuable Professional on 31 Jan 2025 at 10:47:16
    Copy Customer Account from one LE to Another
    Are you sure tht thıs doesn't exıst? Dıd you control form the form or the table? Please check from the table level.
  • ET-29012149-0 Profile Picture
    ET-29012149-0 20 on 30 Jan 2025 at 18:21:34
    Copy Customer Account from one LE to Another
    Sorry, forgot error message, but this account does not exist already:

  • ET-29012149-0 Profile Picture
    ET-29012149-0 20 on 30 Jan 2025 at 18:18:11
    Copy Customer Account from one LE to Another

    When I debug, it shows the dataareaid set to the new company code, get two duplicate record error messages, well it says the record already exists, but it doesn't. 
     
    I thought the onInserted event happened after the initial insert of the record but that record is not in CustTable either.
     
    Thank you for your input.
     
    public static void CustTable_onInserted(Common sender, DataEventArgs e)
    {
        CustTable ct = sender as CustTable;
        CustTable                CustTableTarget;
    
        changecompany('NewCompanyID')
        {
    
            CustTableTarget = null;
    
            ttsbegin;
            buf2Buf(ct,CustTableTarget);
            CustTableTarget.insert();
            ttscommit;
        }
    
        changecompany('OriginalCompanyID'){}
    
    }
     
     
     
  • Layan Jwei Profile Picture
    Layan Jwei 7,679 Super User 2025 Season 1 on 30 Jan 2025 at 17:50:00
    Copy Customer Account from one LE to Another
    Hi,

    can you show us the code and the error?


    maybe it will not work with buf2buf, instead u will need to use change company then fill the fields one by one
  • ET-29012149-0 Profile Picture
    ET-29012149-0 20 on 30 Jan 2025 at 17:20:09
    Copy Customer Account from one LE to Another
    It seems like this should work, but am getting a duplicate record error. It's like the commit on the original account isn't happening until after the oninserted event happens so the company is the same for both. Yet neither record is actually being inserted.
     
  • ET-29012149-0 Profile Picture
    ET-29012149-0 20 on 30 Jan 2025 at 14:33:08
    Copy Customer Account from one LE to Another
    I am trying to figure out how to use the changecompany and buf2Buf. I will let you know if I get it to work.
     
    Thank you.
  • Layan Jwei Profile Picture
    Layan Jwei 7,679 Super User 2025 Season 1 on 30 Jan 2025 at 08:13:23
    Copy Customer Account from one LE to Another
    Ok did u try my suggestion?
  • ET-29012149-0 Profile Picture
    ET-29012149-0 20 on 30 Jan 2025 at 03:48:00
    Copy Customer Account from one LE to Another
    I was trying to create an on_inserted event:
     
    public static void CustTable_onInserted(Common sender, DataEventArgs e)
    {
        CustTable ct = sender as CustTable;
        ct.DataAreaId = 'NewDataAreaID';
        ct.insert();
    }
    And it tells me that DataAreaID is read only and can not be updated. 

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,257 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,028 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans
Loading complete