Hi, good day
I hope this can help you, and give you some hints.
Dynamics 365 Business Central: handling BLOB fields on APIs – Stefano Demiliani
Best Regards
Gerardo
tableextension 50100 "YourTableExt" extends "Your Base Table"
{
fields
{
field(50100; "Your Blob Field"; Blob)
{
Caption = 'Your Blob Field';
}
}
}
codeunit 50100 "Blob Handler"
{
procedure BlobToText(BlobField: Blob) ReturnValue: Text
var
InStream: InStream;
Line: Text;
begin
if BlobField.HasValue() then
begin
BlobField.CreateInStream(InStream, TEXTENCODING::UTF8);
InStream.ReadText(ReturnValue);
end;
end;
procedure TextToBlob(var BlobField: Blob; TextValue: Text)
var
OutStream: OutStream;
begin
Clear(BlobField);
BlobField.CreateOutStream(OutStream, TEXTENCODING::UTF8);
OutStream.WriteText(TextValue);
end;
}
page 50100 "Your API Page"
{
APIVersion = 'v2.0';
APIPublisher = 'yourPublisher';
APIGroup = 'yourGroup';
EntityName = 'yourEntity';
EntitySetName = 'yourEntities';
PageType = API;
SourceTable = "Your Base Table";
layout
{
area(Content)
{
field(blobContent; GetBlobContent())
{
Caption = 'Blob Content';
ApplicationArea = All;
}
// ... other fields
}
}
var
BlobHandler: Codeunit "Blob Handler";
local procedure GetBlobContent(): Text
begin
exit(BlobHandler.BlobToText(Rec."Your Blob Field"));
end;
// If you need to handle incoming data
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
BlobHandler.TextToBlob(Rec."Your Blob Field", blobContent);
end;
}
Key Points to Remember:
André Arnaud de Cal...
292,234
Super User 2025 Season 1
Martin Dráb
230,994
Most Valuable Professional
nmaenpaa
101,156