{"title":"Page.SetSelectionFilter(var Record) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/page/page-setselectionfilter-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/page/page-setselectionfilter-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/page/page-setselectionfilter-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Notes the records that the user has selected on the page, marks those records in the table specified, and sets the filter to marked only.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Page.SetSelectionFilter(var Record) Method","slug":"pagesetselectionfiltervar-record-method","at":0,"chars":2579},{"level":2,"title":"Syntax","slug":"syntax","at":245,"chars":65},{"level":2,"title":"Parameters","slug":"parameters","at":310,"chars":125},{"level":2,"title":"Remarks","slug":"remarks","at":435,"chars":896},{"level":2,"title":"Example 1","slug":"example-1","at":1331,"chars":636},{"level":2,"title":"Example 2 (temporary records)","slug":"example-2-temporary-records","at":1967,"chars":480},{"level":2,"title":"Related information","slug":"related-information","at":2447,"chars":132}],"text":"# Page.SetSelectionFilter(var Record) Method\n> Version: _Available or changed with runtime version 1.0._\nNotes the records that the user has selected on the page, marks those records in the table specified, and sets the filter to \"marked only\".\n## Syntax\n```al\n Page.SetSelectionFilter(var Record: Record)\n```\n## Parameters\nPage\nType: page-data-type\nAn instance of the page-data-type data type.\nRecord\nType: ../record/record-data-type\n## Remarks\nIf all records are selected, marks won't be used.\nIf only the current record is selected on the page, then SetSelectionFilter does the following:\n Sets the current filter group to `0` on the destination record\n Adds filters on the primary key fields that point to the current record of the page\nIf more than one record is selected on the page, then SetSelectionFilter does the following:\n Copies the current key from the page source table to the destination record\n Copies the current sort order from the table to the destination record\n Copies the current filters that are set in all filter groups\n Copies the current filter group\n Marks the selected records and sets the \"marked only\" filter\n> IMPORTANT\n> SetSelectionFilter isn't directly supported on pages based on temporary source tables and must therefore be replaced with a custom page method (see Example 2 in the following).\n## Example 1\nThe following example shows how to use the SetSelectionFilter method to update the record or records from the Contact table that the user has selected on the current page.\n```al\nvar\n    Contact: Record Contact;\n    CRMIntegrationManagement: Codeunit \"CRM Integration Management\";\n    ContactRecordRef: RecordRef;\nbegin\n    CurrPage.SetSelectionFilter(Contact);\n    Contact.Next();\n\n    if Contact.Count = 1 then\n        CRMIntegrationManagement.UpdateOneNow(Contact.RecordId)\n    else begin\n        ContactRecordRef.GetTable(Contact);\n        CRMIntegrationManagement.UpdateMultipleNow(ContactRecordRef);\n    end;\nend;\n```\n## Example 2 (temporary records)\nFor retrieving selected records on pages with a temporary source table, the following example shows how to define a custom method on a page that is based on a temporary Contact table. Other objects need to call the custom method instead of the SetSelectionFilter method.\n```al\nprocedure SetTempSelectionFilter(var TempContact: Record Contact temporary)\nbegin\n    TempContact.Copy(Rec, true);\n    CurrPage.SetSelectionFilter(TempContact);\nend;\n```\n## Related information\npage-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}