How to pass response data from internal/external servlet to successful/error event of form submission validation? | Community
Skip to main content
Level 2
September 14, 2020
Solved

How to pass response data from internal/external servlet to successful/error event of form submission validation?

  • September 14, 2020
  • 3 replies
  • 2604 views

Hi All,

 

I am using ootb form submit action - 'Submit to Rest Endpoint'.

 

  • I am able to hit my post servlet using this submit action.
  • My servlet is returning a response data for eg : "data". It can be any data json or string.
  • On the adaptive form container, I have selected "Use Asynchronous Submission
  • I am using "Form Submission" event on the rule editor of form container.

 

How can I get the response data in my front end javascript which I am writing in rule editor of a form submission event or if not in rule editor what is the best way to get the response data?

 

I know I can write the rule on click event of the submit button and directly hit my servlet and get the response but I want to use Submit action(post.Post.jsp) to achieve it. Is there any way?

 

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 yuvraj1610

I was able to resolve this issue by setting the thank you page URL and the value should be the same as the source page URL where the form is present.

3 replies

Kosta_Prokopiu1
Adobe Employee
Adobe Employee
September 14, 2020

You have chosen the asynchronous submit and it sounds as if you want to handle it individually. This link describes your use case - maybe that will help

https://docs.adobe.com/content/help/en/experience-manager-65/forms/adaptive-forms-advanced-authoring/asynchronous-submissions-adaptive-forms.translate.html

The event of the Submit button might not be the correct place. I think that needs to happen on Form level.

Level 2
September 14, 2020

Thanks , however as per my use case mentioned above I am not handling the submit event on button level. I am doing that at the form level only.

 

Mayank_Gandhi
Adobe Employee
Adobe Employee
September 14, 2020

@yuvraj1610  You can make AJAX call to your post servlet in AEM forms rule editor. Just take care of CORS

 

https://api.jquery.com/jquery.post/

 

http://www.aemcq5tutorials.com/tutorials/aem-forms/implement-autocomplete-adaptive-form/

Level 2
September 14, 2020

Hello Mayank,

 

As mentioned in my question above, I know I can do it using direct ajax call. All I am asking to use ootb submit action of Rest End Point. Is there any way we can get the response in front end form using submit action and not by writing ajax code in the rule editor of submit button on click.

yuvraj1610AuthorAccepted solution
Level 2
September 15, 2020

I was able to resolve this issue by setting the thank you page URL and the value should be the same as the source page URL where the form is present.