Show / Hide Table of Contents

    TempBlob Refactoring Guide

    Overview

    This guide helps developers migrate from the deprecated temporary table QWETB tTempBlob to the new codeunit-based QWETB Temp Blob. The migration improves performance and provides additional functionality while maintaining API compatibility.

    Why Migrate?

    For performance reasons, the temporary table QWETB tTempBlob is being deprecated. The path going forward is to migrate to the codeunit-based implementation QWETB Temp Blob, which offers:

    • Better performance - No direct record semantics overhead
    • Enhanced API - Full superset of original functionality
    • New features - Additional capabilities not available in the table version
    • API compatibility - Easy migration path

    Function Migration Reference

    The following table shows the direct mapping between old and new function names. Each function name links to its detailed documentation.

    Function Mapping Table

    Old (Table QWETB tTempBlob) New (Codeunit QWETB Temp Blob) Notes / Guidance
    ExportToClientFileDialog(FileName: Text): Text ExportToClientFile(FileName: Text): Text New name.
    ExportToClientFileDialog(FileName: Text; Encoding: TextEncoding): Text ExportToClientFile(FileName: Text; Encoding: TextEncoding): Text New name.
    SaveToNavStream(var OS: OutStream) WriteTo(var OS: OutStream) New name.
    ImportFromClientFileDialog(DialogTitle, FromFilter) ImportFromClientFile(DialogTitle, FromFilter) New name.
    ImportFromNavStream(var IS: InStream) From(var IS: InStream) New name.
    ImportFromHttpContent(Content: HttpContent) From(Content: HttpContent) New name.
    ImportFromTempBlob(Temp: Codeunit "QWETB Temp Blob") Copy(Source: Codeunit "QWETB Temp Blob") Use Copy() if needed, or remove.
    ImportFromTempBlob(var SysTemp: Codeunit "Temp Blob") FromTempBlob(SysTemp: Codeunit "Temp Blob") New name.
    ImportFromText(Text) From(String: Text) New name.
    ImportFromText(Text; Encoding) From(String: Text; Encoding) New name.
    GetAsTempBlob(var Temp: Codeunit "QWETB Temp Blob") Target.Copy(Source) pattern Use Copy() if needed, or remove.
    GetAsTempBlob(var SysTemp: Codeunit "Temp Blob") AsTempBlob(var SysTemp: Codeunit "Temp Blob") New name.
    GetAsTempBlob(): Codeunit "Temp Blob" AsTempBlob(): Codeunit "Temp Blob" New name.
    GetAsHttpContent(var Content: HttpContent) AsHttpContent(): HttpContent or WriteTo(var Content: HttpContent) Pick based on existing variable and usage. WriteTo() performs better on large data.
    GetAsJsonObject() AsJsonObject() New name.
    (No old equivalent) AsJsonArray() / AsJsonToken() New capability.
    GetAsText() AsText() New name.
    GetAsText(MaxLength) AsText(MaxLength) New name.
    GetAsText(Encoding) AsText(Encoding) New name.
    GetAsText(Encoding, MaxLength) AsText(Encoding, MaxLength) New name.
    ImportFromBase64(Base64Text) FromBase64(Base64String) New name.
    GetAsBase64() AsBase64() New name.

    Common Refactoring Patterns

    The following examples show the most common migration patterns you'll encounter when updating your code.

    Variable Declaration

    Before:

    Tmp: Record "QWETB tTempBlob" temporary;
    

    After:

    Tmp: Codeunit "QWETB Temp Blob";
    

    File Upload and Encoding

    Before:

    Tmp.ImportFromClientFileDialog('Upload', 'All files (*.*)|*.*');
    Base64 := Tmp.GetAsBase64();
    

    After:

    Tmp.ImportFromClientFile('Upload', 'All files (*.*)|*.*');
    Base64 := Tmp.AsBase64();
    

    Copying Between TempBlob Instances

    Before (indirect):

    Tmp1.GetAsTempBlob(Tmp2);
    

    After:

    Tmp2.Copy(Tmp1);
    

    System TempBlob Interoperability

    Before:

    Tmp.ImportFromTempBlob(SysTmp);
    SysTmp := Tmp.GetAsTempBlob();
    

    After:

    Tmp.FromTempBlob(SysTmp);
    SysTmp := Tmp.AsTempBlob();
    

    Stream Operations

    Before:

    Tmp.SaveToNavStream(OS);
    

    After:

    Tmp.WriteTo(OS);
    

    Text Import Operations

    Before:

    Tmp.ImportFromText(MyTxt, TextEncoding::UTF16);
    

    After:

    Tmp.From(MyTxt, TextEncoding::UTF16);
    

    HTTP Content Handling

    Before:

    Tmp.ImportFromHttpContent(Content);
    Tmp.GetAsHttpContent(Content);
    

    After:

    Tmp.From(Content);
    Content := Tmp.AsHttpContent();
    

    Automated Migration Aids

    Search & Replace Patterns (Regex)

    Use these regex patterns to automate the bulk of your migration. Always manually review all replacements to ensure correctness.

    Important

    Test these patterns on a small subset of your code first. Some replacements may require manual adjustment based on your specific usage patterns.

    Direct Function Name Replacements

    Purpose Find (Regex) Replace
    Type declaration Record\s+"QWETB tTempBlob"\s+temporary Codeunit "QWETB Temp Blob"
    Export method ExportToClientFileDialog ExportToClientFile
    Import client file ImportFromClientFileDialog ImportFromClientFile
    Save to stream SaveToNavStream WriteTo
    Import stream ImportFromNavStream From
    Import HTTP ImportFromHttpContent From
    Import text ImportFromText From
    Import base64 ImportFromBase64 FromBase64
    Get base64 GetAsBase64 AsBase64
    Get text GetAsText AsText
    Get HttpContent GetAsHttpContent AsHttpContent

    Patterns Requiring Manual Review

    The following patterns cannot be automatically replaced and require manual analysis:

    • ImportFromTempBlob( → Choose between:
      • Copy( if copying between two QWETB Temp Blob instances
      • FromTempBlob( if importing from system Temp Blob
    • GetAsTempBlob( → Choose between:
      • AsTempBlob( if converting to system Temp Blob
      • Invert to Target.Copy(Source) pattern if copying between QWETB Temp Blob instances

    Advanced Migration Considerations

    Edge Cases and Special Scenarios

    Direct Field Access

    Issue: Direct field usage such as Rec.Blob.CreateInStream(...) is no longer available.
    Solution: Replace with public streaming APIs:

    • Use CreateInStream() and CreateOutStream() methods
    • Use From() and WriteTo() methods for data transfer

    Table Lifecycle Methods

    Issue: Table-specific calls like Init() and Insert() don't apply to codeunits.
    Solution: Remove these calls entirely - the codeunit handles initialization automatically.

    Public API Compatibility

    Issue: If your extension's public APIs expose the old table type, you need to maintain backward compatibility.
    Solution: Create a transitional shim procedure:

    [Obsolete('Use NewProc with codeunit QWETB Temp Blob', '27.0')]
    procedure OldProc(var Tmp: Record "QWETB tTempBlob" temporary)
    var
        NewTmp: Codeunit "QWETB Temp Blob";
    begin
        // Transitional: convert and forward
        Tmp.GetAsTempBlob(NewTmp);
        NewProc(NewTmp);
    end;
    
    Back to top Copyright © 2020 SmartApps
    Generated by DocFX