Demand forecast synchronization fails between Power Apps and Supply Planning

We’re experiencing persistent timeout issues when syncing demand forecasts from our custom Power Apps form to D365 Supply Planning module. The integration worked fine initially with small datasets, but now fails consistently after processing about 200-300 forecast records.

The Power Apps flow calls the MCP server endpoint, but we’re getting HTTP 504 timeout errors. Looking at the logs, it seems related to batch processing limits, but I’m not sure about the proper OAuth2 scope configuration for Supply Planning operations.


Error: Gateway Timeout (504)
Endpoint: /api/data/v9.2/msdyn_demandforecasts
Batch size: 500 records
Timeout after: 120 seconds

We need guidance on configuring batch sizes, pagination in Power Apps flows, and proper timeout settings. The delays are impacting our weekly planning cycles significantly. Has anyone successfully configured MCP server for large-volume demand forecast synchronization?

Good catch on the OAuth token refresh delay. Let me provide a comprehensive solution addressing all the key areas:

1. MCP Server Batch Size Configuration: Set your batch size to 50-75 records maximum for demand forecast operations. Navigate to System Administration > MCP Server Configuration > Batch Processing and update:


mcp.batch.demandForecast.maxSize=75
mcp.batch.demandForecast.timeout=180

2. Power Apps Flow Pagination Logic: Implement proper chunking in your Power Apps flow. Use the ‘Apply to each’ control with a concurrent limit of 1, and add a 5-second delay between batches:

  • Split your forecast dataset into arrays of 75 records
  • Process each chunk sequentially
  • Include error handling with retry logic (max 3 attempts)
  • Use ‘Scope’ controls to manage transaction boundaries

3. OAuth2 Scope Configuration: Update your Azure AD app registration to include these specific scopes:

  • Dynamics.SupplyChain.ReadWrite (REQUIRED for Supply Planning)
  • Dynamics.SupplyChain.DemandForecast.All
  • offline_access (for token refresh)

In your Power Apps connection, refresh the authentication to pick up the new scopes. This should reduce token refresh time from 15-20 seconds to under 2 seconds.

4. Request Timeout Tuning: Increase the MCP server request timeout in web.config:


<httpRuntime executionTimeout="180" />
<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="2147483647"/>
    </webServices>
  </scripting>
</system.web.extensions>

Also configure your Power Apps HTTP action timeout to 180 seconds to match.

5. Diagnostic Logging: Enable these logging categories in System Administration > MCP Configuration > Diagnostics:

  • MCP.DemandForecast.Sync (Level: Verbose)
  • MCP.OAuth.TokenRefresh (Level: Info)
  • MCP.Batch.Processing (Level: Info)

Monitor the logs for 24-48 hours to establish baseline performance metrics. You should see batch processing complete in 30-45 seconds per chunk with proper configuration.

Additional Recommendations:

  • Schedule large forecast uploads during off-peak hours (early morning)
  • Implement a status tracking table to monitor which batches have been processed
  • Consider using the Data Import/Export Framework (DIXF) for initial bulk loads over 5,000 records
  • Set up Application Insights alerts for MCP timeout events

After implementing these changes, your 500-record dataset should process in approximately 8-10 minutes total (7 batches × 75 seconds average per batch) with much higher reliability. The key is matching batch sizes to your MCP server capacity while ensuring proper OAuth scope configuration to eliminate token refresh delays.


This draft is based on general Microsoft Dynamics 365 knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.

I’ve seen this exact issue before. The 504 timeout is typically caused by trying to process too many records in a single batch through the MCP server. The default batch size limit for MCP operations is usually 100-200 records depending on your configuration, but you’re attempting 500.

You need to implement proper pagination in your Power Apps flow. Break down your forecast dataset into smaller chunks and process them sequentially with appropriate delays between batches.

Thanks Sara. I’ve tried reducing batch size to 100 records, but still getting timeouts intermittently. The MCP server seems to struggle even with smaller batches during peak hours. Should I be looking at request timeout configuration on the D365 side as well? Also uncertain if my OAuth2 scope includes all necessary Supply Planning permissions.

The OAuth2 scope configuration is critical here. For Supply Planning operations through MCP, you need the ‘Dynamics.SupplyChain.ReadWrite’ scope explicitly included in your app registration. Many developers miss this and only include the generic ‘Dynamics.ReadWrite’ scope.

Also check your Azure AD app’s API permissions - ensure ‘msdyn_demandforecasts’ entity has proper create/update permissions granted. The intermittent timeouts during peak hours suggest you might also need to implement retry logic with exponential backoff in your Power Apps flow. The MCP server can get overwhelmed when multiple processes hit it simultaneously.

Tested this on D365 F&SCM 10.0.38 with Power Automate flows — setting mcp.batch.demandForecast.maxSize=75 and adding the 5-second delay between batches eliminated our forecast sync timeouts completely.

Have you enabled diagnostic logging on the MCP server endpoint? That would help identify whether the bottleneck is in the authentication layer, data processing, or database commits. In System Administration, go to MCP Server Configuration and enable verbose logging for the demand forecast operations. You’ll likely see exactly where the 120-second timeout is being consumed.

Enabled diagnostic logging and found the issue - OAuth token refresh was taking 15-20 seconds per batch! Combined with processing time, we were hitting the timeout threshold. The scope configuration was indeed incomplete as James mentioned.