FetchXml Tester aliased attributes

Mar 26, 2014 at 8:41 AM
Hi!

It seems that when you used aliases for attributes, the attribute is completely removed from the result xml.
I can execute a query like this:
<fetch>
    <entity name="account" >
        <attribute name="name" />
        <link-entity name="contact" from="contactid" to="primarycontactid">
            <attribute name="fullname" alias="primary_contact" />
        </link-entity>
    </entity>
</fetch>
The attribute "primary_contact" will not be included at all. However it works when I execute it using another tool or directly in my code.

Would that be possible to fix?

/Jonas
Coordinator
Mar 26, 2014 at 9:27 AM
Edited Mar 26, 2014 at 9:27 AM
Hi,

I can reproduce the problem. Nevertheless, my code does really nothing but performing an ExecuteFetchRequest. Here is the code used:
var request = new ExecuteFetchRequest{FetchXml = e.Argument.ToString()};
var response = (ExecuteFetchResponse)service.Execute(request);

e.Result = response.FetchXmlResult;
Then
txtResponse.Text = IndentXMLString(e.Result.ToString());
I can confirm that the method "IndentXMLString" does not remove anything in the result. So I don't see what I could possibly change.

Pesonnaly, I always used "alias" attribute in the node "link-entity" and not in the node "attribute"
Mar 26, 2014 at 10:09 AM
It is strange, indeed...
I actually didn't expect your code to have removed anything, but I wanted to highlight the problem.
And actually, when I now tried the same with classic old Stunnware Tools, I get the same result as with XrmToolBox.

There are scenarios where we benefit from having attribute aliases.
Expected aliasing is returned when calling:
EntityCollection cEntities = crmService.RetrieveMultiple(new FetchExpression(query));
Edit:
I think I have read somewhere this is now the preferred way to use fetchxml from code, to replace the ExecuteFetchRequest. That is probably why.
Found it in the SDK: http://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.executefetchrequest.aspx
Coordinator
Mar 26, 2014 at 10:12 AM
Ok, I can update the code to use this method instead!

It will be in the next release!
Mar 26, 2014 at 10:17 AM
Fantastic!

However, as you can see from the code sample, there is no result xml returned, instead an EntityCollection is returned... So I guess the output will be a bit more complicated to display :-/

/Jonas
Coordinator
Mar 26, 2014 at 10:19 AM
Exact...

I will see how I can handle this