Search Results for

    Show / Hide Table of Contents

    Temporary Table Usage

    Business Central allows the use of temporary tables for storing data in a session.

    Problem

    Using temporary tables with COSMO Mobile Solution is not possible because each request is handled by a different session. Even updating two fields on a card page is handled by two fully independent sessions.

    Solution

    When data has to be used in multiple sessions, save the data in a normal table and then clean it up when it is no longer needed.

    Built-in Solution for Storing Temporary Data

    COSMO Mobile Solution implements a table designed especially for storing temporary data called "CCS MS Web Service Helper". The following simple example shows how to use it for batch processing when a function is called from a list for two or more selected records.

    1. Extend the "CCS MS Function Helper Type" enum with a new process identifier.
    enumextension 50000 MyCustomProcessExtension extends "CCS MS Function Helper Type"
    {
        value(50000; "MyCustomProcess")
        {
            Caption = 'My Custom Process';
        }
    }
    
    1. Implement an unbound function in an already published codeunit.
    internal procedure CustomBatchProcessForReceiptLines(serviceName: Text; recordId: RecordId; isFirst: Boolean; isLast: Boolean)
    var
        WebServiceHelper: Record "CCS MS Web Service Helper";
        WarehouseReceiptLine: Record "Warehouse Receipt Line";
    begin
        if (serviceName = 'CCSMSWhseReceiptLineWS') and (RecordId.TableNo = Database::"Warehouse Receipt Line") then begin
            if isFirst then
                // clear the temporary data when the function is called on the first selected record
                WebServiceHelper.DeleteRecordByType("CCS MS Function Helper Type"::MyCustomProcess);
    
            // save the current selected record
            WarehouseReceiptLine.Get(recordId);
            WebServiceHelper.InsertRecord("CCS MS Function Helper Type"::MyCustomProcess, WarehouseReceiptLine."No.", '', WarehouseReceiptLine."Line No.");
    
            if isLast then
            begin
                // collect all saved records and run the batch process when the function is called on the last selected record
                WebServiceHelper.GetRecordsByType("CCS MS Function Helper Type"::MyCustomProcess);
                repeat
                    WarehouseReceiptLine.Get(WebServiceHelper."Code 1", WebServiceHelper."Integer 1");
                    MarehouseReceiptLine.Mark(true);
                until WebServiceHelper.Next() = 0;
                WarehouseReceiptLine.MarkedOnly := true;  // 
                WarehouseReceiptLine.FindSet();
                DoBatchProcessOnSelectedReceiptLines(WarehouseReceiptLine);
            end;
        end;
    end;
    
    1. Search for and add the newly created function as an unbound function to the CCSMSItemsWS page customization.
    2. Search for and add this function to the list view.
    3. Define the caption for the unbound function in the required language.
    4. Specify an icon for the unbound function for visual clarity.
    5. After refreshing the schema in the mobile application, the unbound function will appear in the card view and be available for use.


    Feedback
    Submit feedback for this page .

    In This Article
    Back to top 2025 © COSMO CONSULT - Data protection - Imprint