Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Use this event to

Excerpt

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

...

Consider using Steps.Create_ListStepFromListValues() or HeaderField.Create_ListFieldFromListValues() if your lists are short, only requires one field per entry - or needs to be dynamic.


Template

        [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddDataTables''', true, true)]
    local procedure OnGetReferenceData_OnAddDataTables(var _DataTable: Record "MOB DataTable Element"; _MobileUserID: Code[50])
    begin
        with _DataTable do begin
            InitDataTable_DataTable.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)]
    local procedure My01OnGetReferenceData_OnAddDataTables(var _DataTableRecord "MOB DataTable Element"Record "MOB DataTable Element"; _MobileUserID: Code[50])
    var
        CountryRegion: Record "Country/Region";
    begin
        with _DataTable do begin
            InitDataTable_DataTable.InitDataTable('MyCountries');

            if CountryRegion.FindSet() then
                            repeat
                    Create                _DataTable.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)]
    local procedure My02OnGetReferenceData_OnAddDataTables(var _DataTable: Record "MOB DataTable Element"; _MobileUserID: Code[50])
    var
        CountryRegion: Record "Country/Region";
    begin
        with _DataTable do begin
            InitDataTable_DataTable.InitDataTable('MyCountryDetails');

            if CountryRegion.FindFirstFindSet() then
                            repeat
                    Create                _DataTable.Create();
                    SetValue                _DataTable.SetValue('Code', CountryRegion.Code);
                                    _DataTable.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)]
    local procedure My03OnGetReferenceData_OnAddDataTables(var _DataTable: Record "MOB DataTable Element"; _MobileUserID: Code[50])
    var
        SalesHeaderRecord "Sales Header";
        MobCommonMgt: Codeunit "MOB Common Mgt.";
        MobToolboxRecordCodeunit "Sales HeaderMOB Toolbox";
        OptionIndex: Integer;
    begin
        with _DataTable do begin
            InitDataTable_DataTable.InitDataTable('MyDocumentTypes');

            for OptionIndex := MobToolbox.AsInteger(SalesHeader."Document Type"::Quote to SalesHeaderQuoteto MobToolbox.AsInteger(SalesHeader."Document Type"::"Return Order") do begin
                SalesHeader            SalesHeader."Document Type" := MobCommonMgt.AsSalesDocumentTypeFromInteger(OptionIndex);
                Create
            _DataTable.Create();
                SetValue            _DataTable.SetValue('DocumentType', Format(SalesHeader."Document Type"));
            end;
        end;
    end;



Filter by label (Content by label)
showLabelsfalse
showSpacefalse
sorttitle
titleMore examples
excerptTypesimple
cqllabel = "bc" and label = "referencedata" and label = "example" and label = "OnGetReferenceData_OnAddDataTables"

...

VersionChanges
MOB5.15Introduced (supersedes OnGetReferenceData_OnAfterAddListDataAsXml)
MOB5.26Parameter _MobileUserID added.