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 / liquid code, validati...
Power Pages
Unanswered

liquid code, validating a param before fetchxml and error handling?

(0) ShareShare
ReportReport
Posted on by 4
I have a page with liquid code that performs a fetchxml, which is filtered by a guid column. The value it's filtering by uses an id querystring value, but if the id isn't in a guid format (e.g. perhaps a user clicked a link and it truncated the link so it's no longer in a guid format) then it looks like the fetchxml fails, with an error like: "Exception has been thrown by the target of an invocation." - it's a different situation to trying to filter by a guid that doesn't exist - that will not throw an error, you'll just get zero results.

In an ideal world, I'd either be able to pre-validate the id is of a guid format before fetchxml is called, or I want to be able to capture the error when fetchxml fails.  This way you can handle the invalid id gracefully.

Is there really no suitable solution to this without swapping for client side WebAPI calls to fetch the data?
 
Categories:
I have the same question (0)
  • SaiRT14 Profile Picture
    1,990 Super User 2025 Season 1 on at
    Javascript 
    function isValidGuid(guid) {
        var guidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
        return guidRegExp.test(guid);
    }
    var queryId = "{{ request.params.id }}";
    if (isValidGuid(queryId)) {
        // Proceed with your FetchXML call
    } else {
        alert("Invalid GUID");
    }
     

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
DP_Prabh Profile Picture

DP_Prabh 51

#2
rezarizvii Profile Picture

rezarizvii 35

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 33 Most Valuable Professional

Last 30 days Overall leaderboard