Skip to content

[W1][codeunit][102][Import Consolidation from API] OnBeforeGetGLEntries #11713

Description

Why do you need this change?

We want to filter the fetched GL entries of the consolidation on dimension 4.
But we are unable to because the OnBeforeGetGLEntries event doesn't provide the filter string.
The request is also send with a fixed filter.

We could make the request it, but then would have also need to reauthenticate, but against what Url?

Describe the request

A possible solution would be to have the filter part of the event, so we can update the filter string in a subscriber.

    local procedure GetGLEntries(DateFilter: Text; AccountNoFilter: Text): JsonArray
    var
        Filter, Response: Text;
        IsHandled: Boolean;
    begin
        Filter := '/generalLedgerEntries?$filter=' + DateFilter + ' and (' + AccountNoFilter + ')&$expand=dimensionSetLines', true)');
        OnBeforeGetGLEntries(DateFilter, AccountNoFilter, IsHandled, Response, Filter);
        if IsHandled then
            exit(ParseData(Response));
        exit(HttpGet(BusinessUnitAPIBaseUrl + Filter);
    end;
    [IntegrationEvent(false, false)]
    local procedure OnBeforeGetGLEntries(DateFilter: Text; AccountNoFilter: Text; var IsHandled: Boolean; var Response: Text; var Filter: Text)
    begin
    end;

Likewise for OnBeforeGetGLEntriesCountAtDate

    local procedure GetGLEntriesCountAtDate(GLAccountNo: Code[20]; ClosingDate: Date): Integer
    var
        Filter, Response: Text;
        IsHandled: Boolean;
    begin
        Filter :=  '/generalLedgerEntries?$filter=' + GLAccountToFilter(GLAccountNo) + ' and postingDate eq ' + FormatDateForAPICall(ClosingDate));
        OnBeforeGetGLEntriesCountAtDate(GLAccountNo, ClosingDate, IsHandled, Response, Filter);
        if IsHandled then
            exit(ParseCount(Response));
        exit(HttpGetCount(BusinessUnitAPIBaseUrl + Filter);
    end;
    [IntegrationEvent(false, false)]
    local procedure OnBeforeGetGLEntriesCountAtDate(GLAccountNo: Code[20]; ClosingDate: Date; var IsHandled: Boolean; var Response: Text; var Filter: Text)
    begin
    end;

Provide an implementation (optional)

  • I will provide the implementation for this extensibility request

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions