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 / How to handle fetchxml...
Power Pages
Answered

How to handle fetchxml when result is empty

(0) ShareShare
ReportReport
Posted on by

Hello,
I have a fetch xml query via liquid. 

Issue:

{% if colfetchxml.results.entities.size == 0 %}
  {% assign myvar = false %}
{% else %}
  {% assign myvar = true %}
{% endif %}

I keep getting this:
Liquid error: Exception has been thrown by the target of an invocation.


So far I have narrowed down to the me trying to acess these properties even at the first level .results .entities .size

I've tried comparing colfetchxml to null, nil, "" and the result is always that it is not empty/null since i can do colfetchxml.xml | h to return the xml query. 

My assumption is that since the the result is empty, the additional properties are not available. 

How can I evaluate this?

I have checked permissions. 
I have many other fetches written this way and they are working. Partly because all of them has a minimum 1 record requirement or must exist. 

For this one case, it is optional. 



Categories:
I have the same question (0)
  • Verified answer
    JanGenese09 Profile Picture
    on at

    I figured it out:

    instead of checking the size which is not accessible. you can instead evaluated if a property exist. 

    {% if colfetchxml contains 'results'%}
    //the property result exist
    {% else%}
    //
    {% endif %}

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!

Leaderboard > Power Pages

#1
Suriyanarayanan V Profile Picture

Suriyanarayanan V 11

#2
Fubar Profile Picture

Fubar 6 Super User 2026 Season 1

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 5 Most Valuable Professional

Last 30 days Overall leaderboard