microsoft / microsoft/BCApps

[Event Request] Add event to Codeunit 2682 "Data Search Events"

Open
#8,970 3 comments 0 reactions 1 assignee View on GitHub

@BardurKnudsen is already working on this.

Since Jul 9, 2026.

  • #9279 by @BardurKnudsen — closed without merging
AI-Triage Approved event-request Team: Integrations
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

Describe the issue

We want to extend the Search App using the Sales Responsibility filter,in the same way this is done in pages of the Base App. When a user clicks "Show More", the procedure ShowRecords performs the search again.
At this point, there is no possibility to filter the records based on the "Responsibility Center" field.

Expected behavior

To solve this requirement, we need a new Event in Codeunit 2682 (Data Search Events) - add at the end of this codeunit:

/// <summary>
/// Allows adding additional filters to the RecordRef used to display
/// all search result records (page "Data Search Result Records").
/// This event is raised after the search filters have been applied
/// but before the records are displayed, enabling extensions to add
/// security or business logic filters (e.g. Responsibility Center filtering).
/// </summary>
/// <param name="RecordRef">The filtered RecordRef on which all results will be displayed.</param>
/// <param name="TableSubtype">The table subtype (e.g. Document Type) as an integer.</param>
[IntegrationEvent(false, false)]
procedure OnAfterSetSourceRecRef(var RecordRef: RecordRef; TableSubtype: Integer)
begin
end;

The Event must be raised in Page Data Search Results (Page 2682 "Data Search Result Records") in procedure "SetSourceRecRef":

internal procedureRef(
    var RecRef: RecordRef;
    TableSubtype: Integer;
    SearchString: Text;
    NewPageCaption: Text)
var
    DataSearchInTable: Codeunit "Data Search in Table";
    DataSearchEvents: Codeunit "Data Search Events"; // NEW
    FldRef: FieldRef;
begin
    if RecRef.Number = 0 then
        exit;

    DataSearchInTable.SplitSearchString(SearchString, SearchStrings);
    SearchStrings.Get(1, SearchString);
    DataSearchInTable.GetFieldList(RecRef, FieldList);

    SourceRecRef.Open(RecRef.Number);
    FldRef := SourceRecRef.Field(SourceRecRef.SystemModifiedAtNo);
    SourceRecRef.SetView(StrSubstNo(SetViewLbl, FldRef.Name));

    DataSearchInTable.SetFiltersOnRecRef(SourceRecRef, TableSubtype, SearchString);

    // Raise event to allow additional filtering (e.g. Responsibility Center)
    DataSearchEvents.OnAfterSetSourceRecRef(SourceRecRef, TableSubtype);

    TableCaptionTxt := NewPageCaption;
end;

Steps to reproduce
  1. Use the Data Search feature to search for records of a table that has a
    "Responsibility Center" field (e.g. sales documents).
  2. Click "Show More" to open page 2682 "Data Search Result Records", which calls
    SetSourceRecRef and re-runs the search.
  3. In an extension, try to restrict the displayed results to the user's allowed
    Responsibility Center.
  4. Observe that there is no event on the filtered RecordRef in SetSourceRecRef,
    so the extension cannot apply the additional filter and unrelated records remain
    visible.
Additional context

The Base Application already applies Responsibility Center filtering on its standard
pages. We need the same capability for Data Search results so that users only see
records they are allowed to see.

The requested event is minimal, additive, and backward-compatible: it introduces a
single OnAfter… integration event with a var RecordRef parameter, following the
existing event patterns in the Data Search App. It would let extensions add security
and business-logic filters cleanly at the correct point in the pipeline.

I will provide a fix for a bug
  • I will provide a fix for a bug

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.