The Blob data type is one of the most useful types in Business Central. In this article, you will learn what it is and how to use it. From saving images to handling information, downloading data, and showing Blob content, this type is incredibly versatile.

  • What Is The Blob Data Type
  • SubType Bitmap
  • How To Delete A Blob
  • How To Copy One Blob To Another
  • How To Download A Blob
  • Temp Blob Codeunit
  • Media Vs Blob

What Is The Blob Data Type


A BLOB (Binary Large OBject) is a complex data type used to store large binary data. It is commonly used for storing data that does not fit the traditional structure of databases, such as images, documents, or other types of large files.

Basically, it’s a chunk of memory that can store various types of data, such as photos, JSON, XML, PDF, and more.


SubType Bitmap


When a Blob field has Subtype = Bitmap you can upload images directly.

A “plus” sign will be available and you will be able to upload an image from your PC.

When you have a list, you can see the image as a small thumbnail


How To Delete A Blob


There is no built-in way to delete the image. But it’s as simple as building this action:


How To Copy One Blob To Another


Let’s copy the contents from a Blob to another one. In this case from BLOB 1 to BLOB 2.

These are the two methods we need to do it.

A simple way is the following. Assuming the action is called “Copy From Blob 1”, we can do something similar to this:

The key is to read from the origin with Instream and write to the destination with OutStream. And with CopyStream we can copy from one Blob to another.


How To Download A Blob


If you want to download the contents of a Blob field it’s done with “DownloadFromStream” function and it will be downloaded in the “Downloads” folder of your computer.

Note that is important to add the correct extension, “.png” in this case.


Temp Blob Codeunit


Sometimes, you won’t have a Blob field available and you will need a temporary Blob to hold some data. This is done with Temp Blob codeunit.

For example, it is typically used when sending a custom email with an attachment. The attachment is saved temporarily with the Temp Blob codeunit, and then attached with an Instream.

We can store all sorts of data in a Blob field, images, pdfs, large texts, etc.

How To Input Text Into A Blob


In this example, you will learn to input information in a field and save it into a Blob. In BC23 we have the possibility to add “ExtendedDatatype = RichContent“.

So we can input rich text, images, etc.

To save the info, we will use a Blob field, in the item card

And in the page we will save the data when validating, and retrieving it with OnAfterGetRecord

You could even use it as a factbox to show the contents of a Blob. In this case, a JSON.

As you can see, Blob fields are always used along with Instream and OutStream, you can learn more about these data types in the article below:

Media Vs Blob


Microsoft suggests using Media data types over Blob for storing images for the following reasons:

Use the Media or Mediaset data types instead of the Blob data type. The Media and MediaSet data types have a couple advantages over the Blob data type when working with images. First of all, a thumbnail version of the image is generated when you save the data. You can use the thumbnail when loading a page and then load the larger image asynchronously using a page background task. Second, data for Media and MediaSet data types is cached on the client. Data for the Blob data type is never cached on the server. It’s always fetched from the database.

https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/performance/performance-developer#builtindatastructure

You can learn more about media types in the following article.


That´s all. Hope you find it helpful.

Blob Guide In Business Central In 2024

Post navigation


2 thoughts on “Blob Guide In Business Central In 2024

Leave a Reply

Your email address will not be published. Required fields are marked *