{"title":"Query.GetFilters() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/query/queryinstance-getfilters-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/query/queryinstance-getfilters-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/query/queryinstance-getfilters-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":"Returns the filters that are applied to all columns in the query.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":264,"chars":117},{"level":2,"title":"Parameters","slug":"parameters","at":381,"chars":88},{"level":2,"title":"Return Value","slug":"return-value","at":469,"chars":77},{"level":2,"title":"Remarks","slug":"remarks","at":546,"chars":1463},{"level":2,"title":"Example","slug":"example","at":2009,"chars":1696},{"level":2,"title":"Related information","slug":"related-information","at":3705,"chars":133}],"text":"> Version: _Available or changed with runtime version 1.0._\nReturns the filters that are applied to all columns in the query. The following code shows the syntax of the GETFILTERS method. Query is a variable of the Query data type that specifies the query object.\n## Syntax\n```al\nFilter :=   Query.GetFilters()\n```\n> NOTE\n> This method can be invoked using property access syntax.\n## Parameters\nQuery\nType: query-data-type\nAn instance of the query-data-type data type.\n## Return Value\nFilter\nType: ../text/text-data-type\nAll filters of the query\n## Remarks\nThe GetFilterS method returns the filters that are currently set for all data columns and filter rows by the queryinstance-setfilter-method method, queryinstance-setrange-methodmethod, and the ../../properties/devenv-columnfilter-property. The GetFilter method does not return filters that are set on a column's source field by the ../../properties/devenv-dataitemtablefilter-property or global filters that are set by the FilterGroup method.\nYou can call the GetFilterS method multiple times and at any point in the code. If you call the GetFilterS method before the first SetFilter or SetRange method call, then the GetFilterS method returns only filters that are set by the ColumnFilter property of the columns.\nFilters that are set by the SetFilter method and SetRange method are applied to a query when the query is opened by using a call to the Open, the SaveAsXML, or SaveAsCSV methods. You must consider the location of the GetFilterS method with respect to these methods to obtain the results that you want. For example, in the following two code examples, the GetFilterS method will return the filter set by the SetFilter method call. However, in the first example, the filter has been applied to the query dataset; in the second example, the filter has not been applied.\n```al\nQuery.SetFilter(Column, String);\nQuery.Open;\nQuery.GetFilterS;\nQuery.Read;\n```\n```al\nQuery.Open;\nQuery.SetFilter(Column, String);\nQuery.GetFilterS;\nQuery.Read;\n```\n## Example\nThe following AL code example demonstrates how to use the GetFilterS method on a query. The example code sets filters on a query column, and then displays a message when the query is run that indicates the filter on the column.\nThis example requires that you create a query called Customer_SalesQuantity that has the following characteristics:\n Links table 18 Customer with table 37 Sales Lines from the CRONUS International Ltd. demonstration database.\n Includes columns for the Name and No. fields from the Customer table and the Quantity field from Sales Lines table.\n The ColumnFilter property of the Quantity column is set with a filter that includes values greater than 10.\n  The following AL code runs the query and displays a message that contains the filter that is set on a query column. You can add the code to the OnRun trigger of a codeunit, and then run the codeunit to see the results.\n```al\nvar\n    MyQuery: Query \"Customer SalesQuantity\";\n    MyFilter: Text;\n    Text000: Label 'The filters are as follows: %1';\nbegin\n    // Sets a filter to display only sales quantities greater than 10. This overwrites the value of ColumnFilter property.\n    MyQuery.SetFilter(Quantity, '>10');\n    // Sets a filter to display the columns with the value Selangorian Ltd. only.\n    MyQuery.SetFilter(Name, 'Selangorian Ltd.');\n    // Runs the query and applies the filter.\n    MyQuery.Open;\n    // Returns the filters that are on the Quantity column and displays the filters in a message.\n    MyFilters := MyQuery.GetFilterS;\n    Message(Text000, MyFilters);\nend;\n```\nRunning the code returns the following message:\nThe filters are as follows: Quantity > 10, Name = Selangorian Ltd.\n## Related information\nquery-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}