web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Pass D365 CRM context ...
Copilot Studio
Suggested Answer

Pass D365 CRM context into Copilot Studio so Dataverse "Get Row By Id from Selected Environment".

(0) ShareShare
ReportReport
Posted on by
Environment
- Dynamics 365 / Model-driven app (CRM) — side‑pane webresource
- Copilot Studio (Dataverse-connected agent)
- Agent must call Dataverse tools like "Get Row By Id" for whichever CRM record opens the pane
 
Goal
Pass CRM context (table logical name + recordId GUID) from the CRM form into the Copilot agent so Copilot Studio Dataverse tools target the correct table & environment.
 
What I tried
- Passing encoded JSON via Xrm.App.sidePanes.createPane(..., data: encodeURIComponent(JSON.stringify({ entityName, recordId }))) and decoding in the webresource.
- Web Chat flow: request token → create DirectLine → dispatch WEB_CHAT/SEND_EVENT on DIRECT_LINE/CONNECT_FULFILLED with { name: 'crm_context', value: { entityName, recordId } }.
- iframe + postMessage to an embedded Copilot webchat page.
- Note: I saw 401/403 when calling dataverse-backed conversation endpoints from the browser — authentication is a separate concern; this post focuses on context shape & transport.
 
Observed / unknowns I need help with
1. Exact payload and field names Copilot Studio expects so Dataverse tools (Get Row By Id) will use the correct table & environment. Example candidates:
   - { entityName: "account", recordId: "GUID" }
   - { tableLogicalName: "account", id: "GUID", environmentId: "..." }
2. Is entitySetName required, or is logical entityName/table + recordId sufficient?
3. Recommended transport for reliability with Copilot Studio Dataverse tools:
   - WEB_CHAT/SEND_EVENT (Web Chat) with a particular event name?
   - postMessage to an embedded Copilot iframe?
   - server-side injection into session metadata during token creation?
4. Exact event name/structure Copilot expects (example: crm.recordContext, crm_context, or other)?
5. Any Copilot Studio configuration steps (tool input mapping, environment selection, permissions, allowed origins) required so "Get Row By Id" uses the selected Dataverse environment and table.
6. Best practice for multi-entity support (agent invoked from many tables).
 
Example payloads I can test (please confirm preferred)
- Web Chat event example:
  {
    "name": "crm.recordContext",
    "value": { "table": "account", "id": "40....13-000D3A23CB53", "environmentId": "env-guid-optional" }
  }
- postMessage example:
  { "type": "crm_context", "entityName": "account", "recordId": "40D5...CB53" }
 
Request
- Please confirm the exact JSON shape and event name Copilot Studio expects for Dataverse tools (Get Row By Id).
- Recommend the most reliable transport (short justification).
- Any minimal Copilot Studio config steps / docs links to map incoming context to tool inputs.
I have the same question (0)
  • Suggested answer
    MichaelFP Profile Picture
    1,999 Moderator on at
    Hi!
     
    I believe for you scenario is best to you to following the documentation provide by Microsoft on how integrate Copilot in Model Driven Apps -> Use Copilot Studio agents in model-driven apps - Power Platform | Microsoft Learn

    I provide and Example with PCF that you can pass information on the context.
     
    -----------------------------
    If my answer helped you, please give me a thumbs up (👍). 
    If solve your question please mark as answer ✔️. This is help the community.
    If you want talk with me just tag me @MichaelFP 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 633

#2
Vish WR Profile Picture

Vish WR 301

#3
Haque Profile Picture

Haque 219

Last 30 days Overall leaderboard