rappen / FetchXMLBuilder

FetchXML Builder for XrmToolBox and Microsoft Dynamics 365 / CRM
https://fetchxmlbuilder.com/
GNU General Public License v3.0
135 stars 55 forks source link

Be able to use aliases. #1039

Closed trotsallt closed 5 months ago

trotsallt commented 5 months ago

Hi, thx for a great tool. A question, if I use aliases on fields they don't seem to show up at all in the result. Am I doing something wrong or is this something that could be fixed? image image

I can run this in the fetchxml tester tool though and get the result with fields named. image

rappen commented 5 months ago

Hi

First, normally we don't use alias unless you do aggregated queries. But I know, according to the docs, it works. So it works, and it works for me at least.

Second screenshot: I have the same issues, in the "raw" result, it doesn't show up. If I remove alias from attributes, it shows up. At this point I'm not sure if the issue is in FXB or in the SDK. But I see that the SDK has deprecated that request.

Third screenshot: FetchXml Tester always just shows the data returned. In my grid view it's trying to show it with correct column name etc. which my be something I should try to show alias name instead.

My query when I'm trying:

<fetch>
  <entity name='contact'>
    <attribute name='fullname' alias='ThePerson' />
    <attribute name='ownerid' alias='TheOwner' />
    <link-entity name='systemuser' from='systemuserid' to='ownerid' alias='USER'>
      <attribute name='lastname' alias='TheOwnerLastname' />
    </link-entity>
  </entity>
</fetch>

Result in a "not friendly" view: image

Result in a "friendly" view: image

Raw result:

<resultset morerecords='0' paging-cookie='&lt;cookie page="1"&gt;&lt;contactid last="{41388504-F44A-EC11-8C62-6045BD8F5259}" first="{5E7F1131-2DAD-EC11-9840-000D3A2BC35A}" /&gt;&lt;/cookie&gt;'>
  <result>
    <contactid>{5E7F1131-2DAD-EC11-9840-000D3A2BC35A}</contactid>
  </result>
  <result>
    <contactid>{DBD00E67-6E63-EC11-8F8F-000D3A2D112C}</contactid>
  </result>
  <result>
    <contactid>{B8706CDA-EEE4-EC11-BB3C-000D3A3A8AD0}</contactid>
  </result>
  <result>
    <contactid>{2355B467-533E-EC11-8C63-000D3A4A08D0}</contactid>
  </result>
  ...

Querying without aliases:

<resultset morerecords='0' paging-cookie='&lt;cookie page="1"&gt;&lt;contactid last="{41388504-F44A-EC11-8C62-6045BD8F5259}" first="{5E7F1131-2DAD-EC11-9840-000D3A2BC35A}" /&gt;&lt;/cookie&gt;'>
  <result>
    <fullname>Anders Rapp</fullname>
    <ownerid dsc='' type='8' yomi='Jonas Rapp' name='Jonas Rapp'>{B5863A5C-5934-EC11-8C65-000D3A217588}</ownerid>
    <contactid>{5E7F1131-2DAD-EC11-9840-000D3A2BC35A}</contactid>
    <USER.lastname>Rapp</USER.lastname>
  </result>
  <result>
    <fullname>Frederick W. Sturckow</fullname>
    <ownerid dsc='' type='8' yomi='Jonas Rapp' name='Jonas Rapp'>{B5863A5C-5934-EC11-8C65-000D3A217588}</ownerid>
    <contactid>{DBD00E67-6E63-EC11-8F8F-000D3A2D112C}</contactid>
    <USER.lastname>Rapp</USER.lastname>
  </result>
  ...
trotsallt commented 5 months ago

Hi,

Thanks for your answer. It seems you get the same result as I did. Will you continue to investigate it or is it just not possible to implement in FXB? That is, getting the raw result output correct when using attribute-alias.

Regards


Från: Jonas Rapp @.> Skickat: den 11 april 2024 12:10 Till: rappen/FetchXMLBuilder @.> Kopia: Tomas Wall @.>; Author @.> Ämne: Re: [rappen/FetchXMLBuilder] Be able to use aliases. (Issue #1039)

Hi

First, normally we don't use alias unless you do aggregated queries. But I know, according to the docs, it workshttps://learn.microsoft.com/power-apps/developer/data-platform/fetchxml/select-columns#column-aliases. So it works, and it works for me at least.

Second screenshot: I have the same issues, in the "raw" result, it doesn't show up. If I remove alias from attributes, it shows up. At this point I'm not sure if the issue is in FXB or in the SDK. But I see that the SDK has deprecated that requesthttps://learn.microsoft.com/dotnet/api/microsoft.crm.sdk.messages.executefetchrequest.-ctor.

Third screenshot: FetchXml Tester always just shows the data returned. In my grid view it's trying to show it with correct column name etc. which my be something I should try to show alias name instead.

My query when I'm trying:

Result in a "not friendly" view: image.png (view on web)https://github.com/rappen/FetchXMLBuilder/assets/2572253/2103f555-7cf7-4f5c-858c-5eb207b1beb4

Result in a "friendly" view: image.png (view on web)https://github.com/rappen/FetchXMLBuilder/assets/2572253/3e32b178-68d4-4088-a63a-4509ebdae7ba

Raw result:

{5E7F1131-2DAD-EC11-9840-000D3A2BC35A} {DBD00E67-6E63-EC11-8F8F-000D3A2D112C} {B8706CDA-EEE4-EC11-BB3C-000D3A3A8AD0} {2355B467-533E-EC11-8C63-000D3A4A08D0} ... Querying without aliases: Anders Rapp {B5863A5C-5934-EC11-8C65-000D3A217588} {5E7F1131-2DAD-EC11-9840-000D3A2BC35A} Rapp Frederick W. Sturckow {B5863A5C-5934-EC11-8C65-000D3A217588} {DBD00E67-6E63-EC11-8F8F-000D3A2D112C} Rapp ... — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.
rappen commented 5 months ago

I was thinking about any Alias shall override DisplayName in "Friendly" view, and make sure LogicalName are shown in "raw" view. Do you agree with my idea?

I'm working now for solving a bunch of new features, and fixing some bugs. We'll see if I solve this one for this release.

rappen commented 5 months ago

Sorry, I misunderstood your request, I was thinking about View Result and not Friendly.

I have investigating more regarding ExecuteFetchRequest and it just don't return attributes that have an alias. Period. We shouldn't use it.

I have improved the View Result though, with better handling of Alias.

I believe this issue is now "solved", as far as possible. Please reopen it if needed!