I am creating a Report for Business Central, a Purchase Order Report. The Purchase Order page is extended to add Work Description which is a blob data type. I have added the blob field to my Report Extension and now I went to convert the Blob to Text like it is seen in my page. Example: "This is a Test Work Description". I believe I have to use InStream and then Read. Can someone provide example code to assist me in adding this to my report as text?
Asked
Active
Viewed 9,118 times
2 Answers
6
You can find good examples here on the Microsoft documentation: Write, WriteText, Read, and ReadText Method Behavior for Line Endings and Zero Terminators
But I think this is what you need:
procedure GetWorkDescription (PurchHeader: Record "Purchase Header")WorkDescription: Text
var
MyInStream: InStream;
begin
Clear(WorkDescription);
PurchHeader.Calcfields("Work Description");
If PurchHeader."Work Description".HasValue() then begin
PurchHeader."Work Description".CreateInStream(MyInStream);
MyInStream.Read(WorkDescription);
end;
end;

Job
- 86
- 6
-
4The very first time I found something NAV/BC related on StackOverflow, and it works first attempt. Thanks !:) – nlreturns May 05 '21 at 13:59
1
This example worked perfectly Job! I just wanted to add to it. In my Purchase header, I added the following code:
column(WorkDescription; GetWorkDescription())
{
}
Then in OnPreReport() added at the end:
WorkDescription: Text;
Then at the very end added the Procedure:
procedure GetWorkDescription(): Text
var
TypeHelper: Codeunit "Type Helper";
InStream: InStream;
begin
"Purchase Header".CalcFields("Purchase Header"."Work Description");
"Purchase Header".Work Description".CreateInStream(InStream, TEXTENCODING::UTF8);
exit(TypeHelper.ReadAsTextWithSeparator(InStream, TypeHelper.LFSeparator));
end;
With the help of your sample code I was able to generate the actual text!

Abby
- 83
- 1
- 10