At Ifacto, we are (still) working on our product for NAV2013 using PRS. One of the things we also try to accomplish, is ease of setup for the functional consultant during an implementation process. We try to manage this by supplying an “Initialize Setup” button on every place that has some distinct setup.
Most of the time, the users should be happy with the default settings, so why not give an option to create them automatically for them when they make another company?
As for most settings this is actually just an easy function to create, it gets a bit harder when you want to create default Icons or Images. You can’t in any way incorporate them in your data, or can you?
Off course you can do that 🙂
One of the ways that is possible, and also the way we did it, is to convert your image to a base 64 string, paste this into your code and you are good to go. The hardest would then be the creation of the base 64 string itself, and since this could possibly be a long string, make it be split up in several lines.
To automate this, I have created a small .NET tool to actually write the code for you.
You supply a few variable names:
- Variable Name: name of the text variable
- Stream Name: a stream variable to import you image into NAV again
- OutStream Name: since a blob in NAV needs an outstream
- Convert Name: To use the default .NET Convert Class
- Source Table: table to where you wish to import the image
- Source Blob: fieldname in above table in which you want to import the image
Then you select the image by clicking or right mouse clicking the image box and select import, next all you need to do is push the button.
Please note that the code is only tested in NAV2013, quite possibly it could still work in NAV2009, but only on the middle tier since it needs DotNet vars.
Anyway, enjoy this.
One more thing, this tool is published as is, don’t expect a heavily maintained application.
If you wish to put even this generation in NAV, you could basically get the base64 string out of a blob on the following way:
ImageStream := ImageStream.MemoryStream;
IconBase64Text := Convert.ToBase64String(ImageStream.ToArray());
I guess the rest to generate actual C/AL code should not be a big issue anymore then. Image Stream is a DotNet MemoryStream, Convert is the DotNet Convert Class. Remember to set the IconBase64Text to an unlimited text variable.