Dynamics 365 Business Central: loading Configuration Packages from AL

Today I’ve spent few times handling a (not so common I think) scenario where from an extension I need to be able to load a RapidStart package (.rapidstart file) to Dynamics 365 Business Central and apply it.

As explained in my last post, in the cloud environment we need to use Streams for handling files and today I discovered (with pleasure) that Microsoft has modified some methods in codeunit 8620 – Config. Package Import for handling Streams. This permits us to programmatically load a RapidStart package also in the Dynamics 365 Business Central cloud environment and this is the AL code for doing so (in case you need that):

LoadConfigPackageFromAL_01.jpg

We have two methods available in codeunit 8620 – Config. Package Import:

  • ImportAndApplyRapidStartPackageStream: receives a TempBlob record as input and loads and apply the package.
  • ImportRapidStartPackageStream: only loads the package passed as TempBlob argument. This function wants also a Config. Setup record (temporary) as input. To apply the package, you need to call the ApplyPackage method defined in Config. Setup table.

I have only a question: I was not able to load multiple .rapidstart packages in a single step! šŸ˜¦

The solution for this problem could be (alternatively):

  1. Microsoft will add a new methodĀ ImportRapidStartPackageZIPStreamĀ that accepts a ZIP file as input containing multiple .rapidstart files.
  2. Someone gives me a solution šŸ˜€

8 Comments

  1. I am get the following error when trying to Import Rapid start package using ImportAndApplyRapidStartPackageStream.
    A call to System.Xml.XmlDocument.Load failed with this message: Root element is missing.
    can you help what could be the problem?

    Like

    1. I got the same issue here when using this. The same XXX.rapidstart file can be imported via the actions in Configuration Packages Page. Please do let me know if you sort this out. Thanks!!!

      Like

    2. Hi I solved the issue with the following piece of code:

      UploadIntoStream(‘Configuration Package Selection’, ”, ”, FileName, InStr);
      TempBlob.Init();
      TempBlob.Blob.CreateOutStream(OutStr);
      CopyStream(OutStr, InStr);
      ConfigPackageImport.ImportAndApplyRapidStartPackageStream(TempBlob);

      You need an outstream to write data into the TempBlob

      Like

  2. I tried using this code, but it will not compile. The line
    ConfigPackageImport.ImportAndApplyRapidStartPackageStream(TempBlob); give error ‘Argument 1: cannot convert from Record TempBlob to var Codeunit Temp Blob’

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.