Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Use this event to

Create new DataTables ("ListData") that can be used from Steps and HeaderConfigurations.

DataTables are static data in Reference Data, meaning they are loaded on login and cannot change dynamically.

Description

A DataTable is a lists of "entries" sharing a common DataTableId, usually used to fill choices in dropdown-lists at the Mobile Device. DataTables are usually being referenced from Steps or HeaderConfigurations.

An alternative to DataTables is listValues that is aimed at very short lists that will never change, and is not likely to be reused (ie. custom optionvalues).

Consider using Steps.Create_ListStepFromListValues() or HeaderField.Create_ListFieldFromListValues() if your lists are short and will never change (ie. optionvalues).


See also:

OnGetReferenceData_OnAddDataTables


Template

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddDataTables''', true, true)]
    procedure OnGetReferenceData_OnAddDataTables(var _DataTable: Record "MOB DataTable Element")
    begin
        with _DataTable do begin
            InitDataTable('MyCustomDataTableId');   // Replace with your own dataTable identifier to be used with Set_dataTable(...) from Steps and HeaderConfigurations


            // Create your DataTable entries here
            // ...
            ;
        end;
    end;

Example (1)

    // [Example] 01 - Create new custom DataTable based on BC table using a Create_XXX template
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddDataTables''', true, true)]
    procedure My01OnGetReferenceData_OnAddDataTables(var _DataTable: Record "MOB DataTable Element")
    var
        CountryRegion: Record "Country/Region";
    begin
        with _DataTable do begin
            InitDataTable('MyCountries');

            if CountryRegion.FindFirst() then
                repeat
                    Create_CodeAndName(CountryRegion.Code, CountryRegion.Name);
                until CountryRegion.Next() 0;
        end;
    end;

Example (2)

    // [Example] 02 - Create new custom DataTable based on with no use of templates
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddDataTables''', true, true)]
    procedure My02OnGetReferenceData_OnAddDataTables(var _DataTable: Record "MOB DataTable Element")
    var
        CountryRegion: Record "Country/Region";
    begin
        with _DataTable do begin
            InitDataTable('MyCountryDetails');

            if CountryRegion.FindFirst() then
                repeat
                    Create();
                    SetValue('Code', CountryRegion.Code);
                    SetValue('ISOCode', CountryRegion."ISO Code");
                    SetValue('EUCode', CountryRegion."EU Country/Region Code");
                until CountryRegion.Next() 0;
        end;
    end;

Example (3)

    // [Example] 03 - Create new custom DataTable based on optionfield
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddDataTables''', true, true)]
    procedure My03OnGetReferenceData_OnAddDataTables(var _DataTable: Record "MOB DataTable Element")
    var
        SalesHeader: Record "Sales Header";
        OptionIdx: Integer;
    begin
        with _DataTable do begin
            InitDataTable('MyDocumentTypes');

            for OptionIdx := SalesHeader."Document Type"::Quote to SalesHeader."Document Type"::"Return Order" do begin
                SalesHeader."Document Type" := OptionIdx;

                Create();
                SetValue('DocumentType', Format(SalesHeader."Document Type"));
            end;
        end;
    end;



More examples

There are no items with the selected labels at this time.

Version History

VersionChanges
MOB5.15Introduced (supersedes OnGetReferenceData_OnAfterAddListDataAsXml)
  • No labels