TypeHelper.SetBlobString and TypeHelper.ReadBlob doesn't exist in Wave 2
During preparation for the #DirectionsEMEA i moved my demos to the Wave 2 and found that TypeHelper.SetBlobString and TypeHelper.ReadBlob doesn't exist in Wave 2.
Searched here and found this walkthrough

Well, not very helpful.
That is the real solution, that works for me.

TypeHelper.SetBlobString
Original code was
procedure SetRestaurantModel(ModelAsText: Text)
var
TypeHelper: Codeunit "Type Helper";
RecordRef: RecordRef;
begin
RecordRef.GetTable(Rec);
TypeHelper.SetBlobString(RecordRef, FieldNo("My Model"), ModelAsText);
RecordRef.SetTable(Rec);
end;
Wave 2 compatible code
procedure SetRestaurantModel(ModelAsText: Text)
var
OutStream: OutStream;
begin
"My Model".CreateOutStream(OutStream, TextEncoding::UTF8);
OutStream.Write(ModelAsText);
end;
TypeHelper.ReadBlob
Original code was
procedure GetRestaurantModel(): Text
var
TypeHelper: Codeunit "Type Helper";
BlobFieldRef: FieldRef;
RecordRef: RecordRef;
begin
RecordRef.GetTable(Rec);
BlobFieldRef := RecordRef.Field(FieldNo("My Model"));
exit(TypeHelper.ReadBlob(BlobFieldRef));
end;
Wave 2 compatible code
procedure GetRestaurantModel() Content: Text
var
TempBlob: Codeunit "Temp Blob";
InStream: InStream;
begin
TempBlob.FromRecord(Rec, FieldNo("My Model"));
TempBlob.CreateInStream(InStream, TextEncoding::UTF8);
InStream.Read(Content);
end;
Where to search for the inspiration?
Many of the workarounds about how-to-make-your-code-compatible-with-wave-2 could be found in Business Central source files itself.
For this current example I got the inspiration from the Late Payment Prediction source code.

Like
Report
*This post is locked for comments