Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
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. 



  • Verified answer
    JanGenese09 Profile Picture
    on at
    Re: How to handle fetchxml when result is empty

    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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 69 Super User 2025 Season 1

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 49 Most Valuable Professional

#3
Jon Unzueta Profile Picture

Jon Unzueta 43

Featured topics