Dynamics CRM 2011 · Xml

CRM 2011: Fetch Xml and Layout Xml for Link Entity attribute

If you need to display link entity attribute on your custom filtered view, here is the Fetch Xml and Layout Xml should look like:

FetchXml

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
  <entity name='new_entitya'>
    <attribute name='new_entityaid' />
    <attribute name='new_name' />
    <order attribute='new_name' descending='false' />
    <link-entity name='new_entityb' from='new_entitybid' to='new_entitybid' visible='false' link-type='outer' alias='entityb'>
      <attribute name='new_name' />
    </link-entity>
  </entity>
</fetch>

LayoutXml
Note that entityb is the alias set in FetchXml above.

<grid name='resultset' object='10117' jump='new_name' select='1' icon='1' preview='1'>
	<row name='result' id='new_entityaid'>
	<cell name='new_name' width='200' />
	<cell name='entityb.new_name' width='200' disableSorting='1' />
	</row>
</grid>

Cheers – Sy

Advertisements

10 thoughts on “CRM 2011: Fetch Xml and Layout Xml for Link Entity attribute

      1. Hey Sy

        in the above example, can I have a hyperlink on the “entityb.new_name” field so that on click, it will open the linked entity record?

        Cheers
        Sarvesh

      2. Hi Sarvesh,

        For hyperlink, you can just use the lookup field to the entityb in primary entity.

        Cheers,
        Sy

  1. Hi,
    This code helped alot. But I am getting error when I type in some name or text in the look up.

    Error Message:
    ‘Contact’ entity doesn’t contain attribute with Name = ‘new_abcd’

    “new_abcd” is an attribute of account entity and I have made a join between account and contact.

    Can you please suggest me any possible options to fix it or am I missing anything?

    Here is my sample code:
    var fetchXml = ” +
    ” +
    ” +
    ” +
    ” +
    ” +
    ” +
    ” +
    ” +
    ” +
    ” +
    ” +
    ‘ ‘ +
    ” +
    ‘ ‘ +
    ” +
    ” +
    ” +
    ” +
    ”;

    1. Code missing above, I am adding it again

      var fetchXml = ” +
      ” +
      ” +
      ” +
      ” +
      ” +
      ” +
      ” +
      ” +
      ‘ ‘ +
      ” +
      ‘ ‘ +
      ” +
      ” +
      ” +
      ” +
      ”;

    1. Hi Sheenam,

      The article is written for CRM 2011, so may not work for other versions. Feel free to post the solution when you find out.

      Cheers,
      Sy

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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