I have the following FetchXML:
<fetch>
<entity name="list" >
<attribute name="listname" />
<attribute name="listid" alias="List" />
<filter type="and" >
<condition attribute="listname" operator="eq" value="Test 1" />
</filter>
<link-entity name="listmember" from="listid" to="listid" intersect="true" alias="listmember" >
<attribute name="entitytype" />
<attribute name="listmemberid" />
<attribute name="entityid" />
<link-entity name="contact" from="contactid" to="entityid" alias="contact" >
<attribute name="contactid" />
<attribute name="owneridname" />
<attribute name="owneridtype" />
<attribute name="ownerid" />
</link-entity>
</link-entity>
</entity>
The result looks like this:
<resultset morerecords="0" paging-cookie="<cookie page="1"><listid lastnull="1" firstnull="1" /></cookie>">
<result>
<listname>Test 1</listname>
<listmember.entitytype formattedvalue="2">2</listmember.entitytype>
<listmember.listmemberid>{6739D9B9-xxxx-xxxx-xxxx-000D3A3852A3}</listmember.listmemberid>
<listmember.entityid type="2">{039FD4C6-xxxx-xxxx-xxxx-000D3A385A1C}</listmember.entityid>
<contact.contactid>{039FD4C6-xxxx-xxxx-xxxx-000D3A385A1C}</contact.contactid>
<contact.ownerid name="CRM Test" dsc="" type="8" yomi="CRM Test">{5ABA5CBA-xxxx-xxxx-xxxx-D472F64781F6}</contact.ownerid>
</result>
</resultset>
My issue now is that I have a generic way to retrieve the attributes returned by a FetchXml. But since this one has linked entites the aliases are added to the result, like:
<listmember.listmemberid>
So my retrieve will throw an error since I am looking for "listmemberid"
Is there a way to avoid having these aliases added to the result? Specially since the attribute names are unique?
Any ideas to get around this issue?
The only option to override the alias
of the select column which is working - when you do aggregate function and I tested the below working example.
<fetch top="50" aggregate="true" >
<entity name="account" >
<attribute name="businesstypecode" alias="test" groupby="true" />
<link-entity name="contact" from="accountid" to="accountid" link-type="inner" alias="acc" >
<attribute name="accountrolecode" alias="testing" groupby="true" />
</link-entity>
</entity>
</fetch>
Result:
test testing
1 3
1
This didn't work. I don't know why, maybe limitation of fetchxml.
<fetch top="50" >
<entity name="contact" >
<attribute name="fullname" />
<link-entity name="account" from="accountid" to="accountid" alias="acct" >
<attribute name="name" alias="acctNAME" />
</link-entity>
</entity>
</fetch>
Result:
fullname acct.name
arun account arun account
Even with the Query Expression, you will get a special datatype called AliasedValue
to handle this, so this is intended behavior. Read more