Skip to main content
Community site session details

Community site session details

Session Id : nCxn4grFDmiFn885yabKiZ
Power Pages - Customize & Extend
Answered

How to handle fetchxml when result is empty

Like (0) ShareShare
ReportReport
Posted on 30 Jan 2024 00:03:34 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 30 Jan 2024 at 02:35:07
    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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June 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
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 2

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 2

#3
surya narayanan Profile Picture

surya narayanan 35

Featured topics

Loading complete