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):
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):
- Microsoft will add a new methodĀ ImportRapidStartPackageZIPStreamĀ that accepts a ZIP file as input containing multiple .rapidstart files.
- Someone gives me a solution š
how can we do it while app is installing without user interaction?
LikeLike
I think you cannot do that in an Install codeunit. You can do that in the wizard when installing the extension.
LikeLike
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?
LikeLike
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!!!
LikeLike
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
LikeLike
Yes, absolutely! This is my cut & paste error. Thanks for signaling.
LikeLike
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’
LikeLike
In v18 (current release) Record TempBlob is not available but there’s codeunit TempBlob now. You need to adapt that code (change parameters).
LikeLike