Global error handling | Community
Skip to main content
ajur
Level 2
March 5, 2021
Solved

Global error handling

  • March 5, 2021
  • 2 replies
  • 1082 views

Hello to everybody,

I developed a form with a custom submit action which calls a service. This service calls an API endpoint to save some data. In this process anything can go wrong like connection errors and so on. So then my service returns an error code 500.

In this case the AEM Form shows an alert box with an AEM Forms error code "AEM-AF-901-004". But I don't want to show this alert box. In all backend error cases, I will show to the user a styled error message above the form like "Something went wrong. Please try again later!". I can't find a description how to define such global error messages. But actually it is a common case, right? 

Can you give me some links or hints how to do it?

Regards, Andrea

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Pulkit_Jain_

@ajur 

AEM Forms provides out-of-the-box success and error handlers (client-side functions that are executed based on the server response) for form submissions. Here you can write rules[0] at the form level to override default handlers.

Hopefully, this should serve the purpose.

 

 

[0] - https://experienceleague.adobe.com/docs/experience-manager-65/forms/adaptive-forms-advanced-authoring/asynchronous-submissions-adaptive-forms.html?lang=en#custom 

2 replies

ajur
ajurAuthor
Level 2
March 12, 2021

Hello,

I found a solution for my problem but nowhere a good documentation/HowTo of it. So following steps I've done:

  1. Create a text component within you form, where the error message should be shown and type in your error text.
  2. In the properties dialog give the text component a "speaking" name, tick the "Hide object" checkbox to hide it initially and save the properties.
  3. Select the form container and open the rules editor.
  4. Create a new rule and select "WHEN form submission fails  THEN show 'name of your text component'".
  5. Save the rule
  6. Open the properties dialog of the form and tick the checkbox "Use asynchronous submission" in section "Submission" and save the properties.

Unfortunately I don't know how to do it without asynchronous submission. Maybe I have to change something in my custom submit action to add a parameter which I can check in a rule or something different.

Regards, Andrea

Pulkit_Jain_
Adobe Employee
Pulkit_Jain_Adobe EmployeeAccepted solution
Adobe Employee
March 26, 2021

@ajur 

AEM Forms provides out-of-the-box success and error handlers (client-side functions that are executed based on the server response) for form submissions. Here you can write rules[0] at the form level to override default handlers.

Hopefully, this should serve the purpose.

 

 

[0] - https://experienceleague.adobe.com/docs/experience-manager-65/forms/adaptive-forms-advanced-authoring/asynchronous-submissions-adaptive-forms.html?lang=en#custom