Retrieve data using FetchXml with multiple link entities in CRM 2011

Posted: November 30, 2012 in Code Snippets, CRM 2011

In my example below i’m going to retrieve link entities opportunity and orders in Contact entity.


Below is the fetch xml code:

string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
                                    <entity name='contact'>
                                        <attribute name='fullname' />
                                        <attribute name='contactid' />
                                        <link-entity name='opportunity' from='customerid' to='contactid' link-type='outer'>
                                            <attribute name='name' />
                                            <attribute name='description' />
                                        <link-entity name='salesorder' from='customerid' to='contactid' link-type='outer'>
                                            <attribute name='name' />
                                            <attribute name='ordernumber' />

            var result = service.RetrieveMultiple(new FetchExpression(fetchXml));

Hope is helps 🙂

  1. krishna says:

    im new to crm….can u please explain what are from,to and link type in link entity…..thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s