[Event Request] Add event to Codeunit 2682 "Data Search Events"
@BardurKnudsen is already working on this.
Since Jul 9, 2026.
- #9279 by @BardurKnudsen — closed without merging
- 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
- Use the Data Search feature to search for records of a table that has a
"Responsibility Center" field (e.g. sales documents). - Click "Show More" to open page 2682 "Data Search Result Records", which calls
SetSourceRecRefand re-runs the search. - In an extension, try to restrict the displayed results to the user's allowed
Responsibility Center. - Observe that there is no event on the filtered
RecordRefinSetSourceRecRef,
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.