web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Portal - How to test my custom error

(2) ShareShare
ReportReport
Posted on by 9

Hi everyone, 

I have followed this article to setup a custom error for my portal, this is what I had done:

1. Go to Portal Actions > Enable custom errors.

2. Go to Portal Management > Content Snippets > Create a new snippet named Portal Generic Error using my custom HTML.

pastedimage1592559413693v1.png

Now, I want to test if my custom error is working and showing correctly.

However, I don't know how to create an error for testing purpose of this custom error.

Can anyone help me to break my portal for testing my custom error message?

Thank you and best regards,

Adrian Nguyen

I have the same question (0)
  • Adrian Nguyen Profile Picture
    9 on at

    Any suggestion for this?

  • Suggested answer
    Adrian Nguyen Profile Picture
    9 on at

    Found a way to break my portal: Add any html tag (example <p>) into an entity form and submit.

  • Suggested answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    HI,

    If your problem is resolved, mark this thread verified so that it will be helpful for other community members.

    If found helpful, Please mark my answer verified.

  • Suggested answer
    CU28030558-0 Profile Picture
    2 on at
    Disabling the Web Template - Template worked for me.
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    7,841 Moderator on at
    Hello Adrian,
     

    You've correctly set up the custom error handling for your Power Apps portal. Now, you need a way to force an error to trigger the display of your "Portal Generic Error" content snippet.

    Here's how you can create an error for testing purposes:

    1. Using Web Page Access Control Rules (Simplest):

    • Create a Restrictive Rule:

      • Go to Portal Management > Web Page Access Control Rules.
      • Create a new rule.
      • Set the Website to your portal.
      • Set the Web Page to a page you want to test (e.g., your home page or a specific page).
      • Set the Right to "Read".
      • Under Web Roles, leave it blank (meaning no roles have access).
      • Save the rule. 

    • Test:

      • Open your portal in an incognito/private browser session (to avoid any cached logins).
      • Navigate to the page you specified in the rule.
      • Since no roles have access, you should see your custom "Portal Generic Error" message.

      Explanation: This method forces an authorization error because no user (including anonymous) is allowed to read the page.

    2. Using Liquid Template Errors (More Technical):

    • Find a Liquid Template:

       

      • Locate a page template or content snippet that uses Liquid code.

    • Introduce an Error:

       

      • Add some incorrect Liquid code to the template. For example:

        • {{ unknown_variable }} (references a non-existent variable)
        • {{ page | invalid_filter }} (uses an invalid filter)
        • {% if page.unknown_property %} (accesses a non-existent property)  

    • Test:

       

      • Navigate to the page where you modified the Liquid code.
      • You should see your custom "Portal Generic Error" message.

      Explanation: Liquid errors are caught by the portal's error handling and will trigger the generic error page.

    3. Using JavaScript Errors (If Applicable):

    • Add JavaScript to a Page:

       

      • If your page has custom JavaScript, add a line that will cause an error:

        • undefined_variable.property; (accesses a property of an undefined variable)
        • throw new Error("Test Error"); (throws a custom error)  

    • Test:

      • Open the page in your browser.
      • Open the browser's developer console (F12).
      • Trigger the JavaScript error (e.g., by clicking a button that executes the bad code).
      • You might see the JavaScript error in the console, but the portal's custom error page should also be displayed.

      Explanation: JavaScript errors can sometimes be caught by the portal's error handling, especially if they occur during the page's initial rendering.

    Important Notes:

    • Clear Cache: After making changes, clear your portal's cache (using the "Clear cache" option in the portal admin toolbar).
    • Incognito/Private Browser: Use an incognito/private browser to ensure you're not seeing cached content or logged-in user behavior.
    • Debugging: If your custom error message isn't showing up, double-check the "Portal Generic Error" content snippet for typos or incorrect HTML.
    • Real Errors: Remember that these are forced errors for testing. Real errors in your portal should be addressed to prevent them from happening in production.

    •  

    By using these methods, you should be able to trigger your custom error message and verify that it's working as expected. Choose the method that best fits your testing needs and technical comfort level.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak

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 Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 182 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans