Performance Tuning Webservices in Dynamics 365 Business Central: Apply Filters to Your Webservice Request

By Jake Oetinger | July 12, 2022

Webservices taking a long time to run? Reduce the size of your response and get fewer records returned by using filters in your webservice request.

Using filters ($filter) in your webservice request will reduce the number of records returned and increase the overall performance of your system and integration.

Using the $select option is a great way to remove unnecessary fields from the webservice response and reduce the payload size.

Filters are important because they allow you to identify and use the specific data you need at a specific time. Whether you need to respond to an inquiry using data or need a specific data set for a presentation, filters allow you to focus solely on what you need and cut out the noise of data that isn't relevant to what you are doing.

Below is an example using Postman and CRONUS database. In the example we limit the number of fields to two and the number of customers to only ones that start with the letter A:$select=id, displayName&$filter=startswith(displayName, 'A')

Apply Filters to Webservices in Dynamics 365 Business Central $select $filter

Apply Filters to Webservices in Dynamics 365 Business Central Value

You can visit this Microsoft blog to learn more about Webservice's filter documentation.

Using Application Insights?

Application Insights is a diagnostic tool you can use to determine why your Dynamics 365 Business Central system is behaving a certain way. This can include gathering information on extensions, diagnosing a slow-down in processing, or giving you a view of the traffic and data running through your system.

In this scenario, you can use the event ID RT0008 to view incoming webservice telemetry data. You can use the sample query below to apply filters to your webservice request.

Learn more about Application Insights here.

Sample Query

| where timestamp > ago(60d)
| where customDimensions.aadTenantId == 'YOUR AAD ID HERE' and isnotempty( 'YOUR AAD ID HERE')
| where customDimensions.environmentName == 'YOUR ENVIRONMENT NAME HERE' and isnotempty( 'YOUR ENVIRONMENT NAME HERE')
| where customDimensions.alObjectType <> ''
| where customDimensions.eventId == "RT0008"
//| where toupper(customDimensions.category) contains "API" //Change category to filter on the web service category "API", "ODATA", "SOAP"
| extend _processingTimeMS = toreal(totimespan(customDimensions.serverExecutionTime))/10000
| project
["Timestamp"] = timestamp,
["Category"] = toupper(customDimensions.category),
["Endpoint"] = tostring(customDimensions.endpoint),
["Object Type"] = tostring(customDimensions.alObjectType),
["Object No."] = tostring(customDimensions.alObjectId),
["Object Name"] = tostring(customDimensions.alObjectName),
["Processing Time"] = _processingTimeMS,
["Publisher"] = tostring(customDimensions.extensionPublisher),
["Extension Name"] = tostring(customDimensions.extensionName)
| sort by ["Timestamp"] desc


We have a team of Business Central experts ready to assist you! Please get in touch with us if you have any questions.

You can read more about this on the Microsoft Blog.

Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!