web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Fetchxml not honoring ...
Power Pages
Unanswered

Fetchxml not honoring useraworderby attribute for ordering choice fields by value

(1) ShareShare
ReportReport
Posted on by 4
I have a choice field (crdxx_rating) defined on a table for ratings:
In my liquid fetchxml I want it to order the results by the choice value descending. The documentation says that the fetch attribute 'useraworderby' set to true should do this, but even when setting that attribute I still get the results ordered by Label and records with the value 'Unrated' are coming first followed by '5-Star, 4-Star, etc' due to the string order. Why is fetchxml from liquid not honoring this fetchxml attribute for raw choice value ordering?
 
Fetchxml in liquid on the page:
    {%- fetchxml sessionImagesLoad -%}
    <fetch useraworderby="true" mapping="logical">
      <entity name="crdxx_image">
        <attribute name="crdxx_filename" />
        <attribute name="crdxx_imagestatus" />
        <attribute name="crdxx_imagetype" />
        <attribute name="crdxx_rating" />    
        <filter>
          <condition attribute="crdxx_imagetype" operator="eq" value="100" />
          <condition attribute="createdon" operator="le" value='{{ "today" | date: "yyyy-MM-dd HH:mm:ss" }}' />
          <condition attribute="statecode" operator="eq" value="0"/>
        </filter>
        <order attribute="crdxx_rating" descending="true" />
      </entity>
    </fetch>
{%- endfetchxml -%}
Categories:
I have the same question (0)
  • Christian Leverenz Profile Picture
    1,214 on at
    Hi,
    sounds like a strange hint, i know: the documentation for power pages says, you should not use selfclosing tags ( https://learn.microsoft.com/en-us/power-pages/configure/liquid/template-tags#fetchxml ) . May be, MS is serious about this, just give it a try to use 
    <order attribute="crdxx_rating" descending="true"></order>
    instead of 
    <order attribute="crdxx_rating" descending="true" />
    So, don't blame me for the strange answer, i just stumbled across this a few days ago and use it without questioning :-) (this would also apply for the attribute tags)
     
    Another hint could be, that the dataverse is smart to use the ordering which is in the stringmap. Sp, does using descending="false" change anything?
     
    Hope this all does not sound too stupid,
      Christian
  • DP-01081438-0 Profile Picture
    4 on at
    Thanks for the suggestion Christian, but after changing the fetchxml to remove the self-closing tags for everything it didn't make a difference. The order is still being based on the string name and not the value of the choice option. The only way I have found around it is to rename my choice from 'Unrated' to '0 star' and now of course it will order properly because all the choice labels start with a number value. It just looks (and feels) dumb that I have to use an undesirable choice name because the useraworderby attribute does nothing when used in fetchxml executed by Power Pages code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 56

#2
Valantis Profile Picture

Valantis 46

#3
rezarizvii Profile Picture

rezarizvii 25

Last 30 days Overall leaderboard