custom action on AEM form | Community
Skip to main content
manikanthar1295
April 11, 2022

custom action on AEM form

  • April 11, 2022
  • 3 replies
  • 1321 views

Hi Team,

 

I have created simple form it contains 4 fields like 

 

First Name

Last Name

DOB

Gender

 

After submitting i need to call servlet to send this to some other system.

 

How i can send these data to my custom servlet 

I have created my path based servlet and path is /bin/aem/customerdata

 

Can some one help me here 

 

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

3 replies

Pulkit_Jain_
Adobe Employee
Adobe Employee
April 11, 2022

@manikanthar1295 

You can post the data to the sling servlet's doPost method using the JQuery AJAX request.

 

     $.ajax({
        type: 'POST',
        url:'/bin/myServlet',
        data:{'First Name' : val1,'Last Name' : val2},          //passing values to servlet
        success: function(msg){
            //Success logic
        }
    });

Hope this helps!

manikanthar1295
April 11, 2022

@pulkit_jain_ 

 

Thanks for your reply.

 

I am using the adaptive form  which contains 4 fields

First Name

Last Name

DOB

Gender

 

Can i use same $ajax call in Adaptive form as well.

if yes where i need to write that ajax call code is 

manikanthar1295
April 12, 2022

@manikanthar1295 

You can edit the servlet call sample shared previously to include 4 parameters. 

This AJAX call should be invoked as part of the submit action rules of the adaptive form. You can read more about rule editor here[0]

 

[0] - https://experienceleague.adobe.com/docs/experience-manager-65/forms/adaptive-forms-advanced-authoring/rule-editor.html?lang=en#understanding-a-rule 


Hi,

as per your suggestion i am written code like below is it correct way to write

 

 

 

Mayank_Gandhi
Adobe Employee
Adobe Employee
April 14, 2022

@manikanthar1295

 Step 1: Test your servlet via postman.

Step 2: If it works via postman then make an AJAX call from the script editor to the servlet.