Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to reverse fetchxml query results

(0) ShareShare
ReportReport
Posted on by

I use fetchxml to query an entity.

{% fetchxml campaigns_Query %}
    .......
{% endfetchxml %}
{% if request.params['t'] %}
    {% assign result = campaigns_Query.results.entities %}
{% else %}
    {% assign result = campaigns_Query.results.entities | reverse %} // I need reverse result here, But, The "reverse" is not effective.
{% endif %}
{% for item in result limit: pageSize %}
   ......
{% endfor %}

*This post is locked for comments

  • RE: How to reverse fetchxml query results

    Hi Dmytro Rutkovskyi,

    If using Javascript, I need more js code to show html to client. I want to use less code do more work.

  • Suggested answer
    Dmytro Rutkovskyi Profile Picture
    Dmytro Rutkovskyi 1,835 on at
    RE: How to reverse fetchxml query results

    At least you can put the values from the fetchxml into Javascript Array, revert it, and use it to render the results.

  • RE: How to reverse fetchxml query results

    Hi Dmytro Rutkovskyi

    I can't order in query, Because filter has lot's calculate to query result.

    So, Do you have another suggest for me, Thank you.

  • Suggested answer
    Dmytro Rutkovskyi Profile Picture
    Dmytro Rutkovskyi 1,835 on at
    RE: How to reverse fetchxml query results

    Hello,

    reverse works on arrays in liquid, in this case, it's more enumerable list which you can go only in one direction.

    I suggest you add the condition to your {%fetchxml campaigns_Query  %} like:

    {% fetchxml campaigns_Query %}
    .......
    {% if request.params['t'] %}
     <order attribute="someattr" descending="false" />
    {% else %}
     <order attribute="someattr" descending="true" />
    {% endif %}
    ......
    {% endfetchxml %}

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans