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 :
Small and medium business | Business Central, N...
Suggested Answer

Synchronizing Data between stages directly via BC API using configuration packages?

(7) ShareShare
ReportReport
Posted on by 90
Hi, I am trying to sync data between the master companies of our different stages test, prelive, live using configuration packages and a direct API. 
( Specifically the fucntion ImportPackageXMLWithCodeFromStream  in Codeunit "Config. XML Exchange" ). That function doesn't work cross-company.I created an API but unfortunately it only ever applies the package to the current company. 
 So right now my approach is: 
 Save relevant data in a buffer table. 
 startSession in the new company. 
 retrieve & apply the package data.
 Is there a easier way to change the company while keeping the package data ( large string )?
 
I have the same question (0)
  • Suggested answer
    Dhiren Nagar Profile Picture
    2,680 Super User 2026 Season 1 on at
    Hi,
     
    I think you must be having a full license and hence a free power automate license too (Given by Microsoft with Essential or premuim).
     
    So what you can do I think is set up a manually triggered Automate workflow using Business Central triggers and actions where you can do the following steps. I am putting some help links at the end to create power automate flow.
     
    1 - Retrieve the Config Package Record and its content from the Source Company and environment.
    2 - Now you can run a loop for the number of environments you want to copy your data.
    3 - In each loop you can list the companies with the Get Companies API. (The name of the API can be different, you need to check).
    4 - With this create another loop to insert a record in each of this companies.
    5 - Run action "Import".
     
    If no error and clean data this should automate your work. I've not tried it but thanks to your idea now I can do it. Now this flow you can also run through HTTP Call to Power Automate. Check HTTP trigger in Power Automate - Trigger Power Automate Flow Through Business Central Action.
     
    Now you can also do the same thing by creating a report in Business central which does the same thing by creating the same loop and API calls and Web Action calls.
     
    I know I am explaining on high level, but if you managed to find Config Package API, I think you can understand the above explanation too.
     
    Let me know if you have any question. Mark answer verified if this helps.
     
    Power Automate help links.
     
    Regards,
    Dhiren.
  • Suggested answer
    OussamaSabbouh Profile Picture
    11,005 Super User 2026 Season 1 on at
    Hello,
     ImportPackageXMLWithCodeFromStream is not cross-company by design, and APIs always run in the current company, so what you’re seeing is expected. The simplest approach is not StartSession, but to keep the package as a stream (TempBlob) and explicitly switch company context before calling the import. If supported in your version, call ChangeCompany() on the Config. XML Exchange codeunit and then import the stream; the XML itself doesn’t need to change or be reloaded. If you must persist the package between companies or calls, store it once in a Blob table with DataPerCompany = false, then read it back and import per company. Buffer tables + sessions work, but they’re overkill and harder to maintain.
    Regards,
    Oussama Sabbouh
  • Suggested answer
    YUN ZHU Profile Picture
    98,014 Super User 2026 Season 1 on at
    Hi, hope the following can give you some hints.
    How to create Configurations packages with AL in Business Central
     
    Thanks.
    ZHU
  • CC-05111201-0 Profile Picture
    90 on at
     
      If supported in your version, call ChangeCompany() on the Config. XML Exchange codeunit and then import the stream
     
    Hi , thanks , which version would that be ?  I'm using BC27 cloud ( and it doesn't seem to work ) 

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,091 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,032 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 946 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans