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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Passing current contact to a complex query

(1) ShareShare
ReportReport
Posted on by 21
Hi,
I have a complex query that returns a list of projects that a contact is related to.  To return the list of projects, I have a fairly complex fetchxml query that i want to pass the current contact to as a filter expression, how do I do this?
cheers
Steve.
  • André Arnaud de Calavon Profile Picture
    307,801 Super User 2026 Season 2 on at
    Hi wigneys1,
     
    Can you tell us for which exact Dynamics 365 application you are seeking help on this forum?
  • wigneys1 Profile Picture
    21 on at
    It's a model driven app built on Dynamics 365 Sales Enterprise...
  • André Arnaud de Calavon Profile Picture
    307,801 Super User 2026 Season 2 on at
    Thanks for your reply. I'm not able to help with this. Let's wait for another volunteer to chime in.
  • MH-16081421-0 Profile Picture
    11 on at
    Hi Steve.
     
    "I want to pass the current contact to as a filter expression" sounds like you are trying to create a generic FetchXML. Is this correct? If so, would you mind posting the FetchXml? At least the relevant parts would help.
     
    Michael
  • Suggested answer
    SeanRoque Profile Picture
    4 on at
    If you're talking about using a QueryExpression in your code and you want to pass your fetch as a filter, you can use the SDK FetchXmlToQueryExpressionResponse to convert your fetchxml string (use string format to include your current contact id) to a QueryExpression and use that. See this post on how you might go about doing that https://community.dynamics.com/blogs/post/?postid=3f01c4e7-2113-4a1b-b728-e7d2d6362c71
     
    If you just want a way to retrieve the list of projects, I recommend the XrmToolBox tool "Export To Excel" https://www.xrmtoolbox.com/plugins/Ryr.XrmToolBox.ExportToExcel/ has a button that utilizes another tool "FetchXML Builder"  https://www.xrmtoolbox.com/plugins/Cinteros.Xrm.FetchXmlBuilder/ to let you edit the fetch, and extract records as a spreadsheet.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 61 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 38 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 22 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans