[EVENT] Also add RecordID to the current event that is already there.

Open Beginner friendly
#10,940 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active

Research direction

Start in codeunit 1535 "Approvals Mgmt." and locate FindOpenApprovalEntryForCurrUser and its OnFindOpenApprovalEntryForCurrUserOnAfterApprovalEntrySetFilters event. Update the event invocation and declaration to include RecordID, then verify that the codeunit compiles and the event exposes both ApprovalEntry and RecordID to subscribers.

Written by the indexing model from the issue text.

Description

Approved event-request ext-ready-to-implement Team: Integrations
Why do you need this change?

I need to build a different filter for the Approval Entry and I need the RecordID for this.

Describe the request

In codeunit 1535 "Approvals **Mgmt." there is this function

 procedure FindOpenApprovalEntryForCurrUser(var ApprovalEntry: Record "Approval Entry"; RecordID: RecordID): Boolean
    begin
        ApprovalEntry.SetRange("Table ID", RecordID.TableNo);
        ApprovalEntry.SetRange("Record ID to Approve", RecordID);
        ApprovalEntry.SetRange(Status, ApprovalEntry.Status::Open);
        ApprovalEntry.SetRange("Approver ID", UserId);
        // Initial check before performing an expensive query due to the "Related to Change" flow field.
        if not ApprovalEntry.IsEmpty() then
            ApprovalEntry.SetRange("Related to Change", false);

        **OnFindOpenApprovalEntryForCurrUserOnAfterApprovalEntrySetFilters(ApprovalEntry);**
        exit(ApprovalEntry.FindFirst());
    end;

In here there is the event OnFindOpenApprovalEntryForCurrUserOnAfterApprovalEntrySetFilters. It now olny contains the Approval Entry. I would also like to include the RecordID

SO the function becomes

 procedure FindOpenApprovalEntryForCurrUser(var ApprovalEntry: Record "Approval Entry"; RecordID: RecordID): Boolean
    begin
        ApprovalEntry.SetRange("Table ID", RecordID.TableNo);
        ApprovalEntry.SetRange("Record ID to Approve", RecordID);
        ApprovalEntry.SetRange(Status, ApprovalEntry.Status::Open);
        ApprovalEntry.SetRange("Approver ID", UserId);
        // Initial check before performing an expensive query due to the "Related to Change" flow field.
        if not ApprovalEntry.IsEmpty() then
            ApprovalEntry.SetRange("Related to Change", false);

        **OnFindOpenApprovalEntryForCurrUserOnAfterApprovalEntrySetFilters(ApprovalEntry, RecordID);**
        exit(ApprovalEntry.FindFirst());
    end;

and the event becomes

[IntegrationEvent(false, false)]
local procedure OnFindOpenApprovalEntryForCurrUserOnAfterApprovalEntrySetFilters(var ApprovalEntry: Record "Approval Entry";RecordID: RecordID)
begin
end;
Provide an implementation (optional)
  • I will provide the implementation for this extensibility request
Dominant language
AL
Stars
683
Forks
459
Avg merge
2d 20h
Merged PRs (30d)
621

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/BCApps

All issues in microsoft/BCApps

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.