Expand my Community achievements bar.

SOLVED

Retrieving data from custom service and displaying in aem adaptive forms

Avatar

Level 2

Hi,

I am working on an adaptive form 6.3.

I am working on the scenario,

  1. where I have capture the user entered form data
  2. send it to the custom service
  3. After my business logic is done, I have to return some value back from my service back to the form and that value should be displayed to the user.

The first 2 steps, I have achieved it by writing custom submit action.But I don't have clue how to get back the value from service and display that in the adaptive form.

Can someone please guide me in that approach.

Regards,

Hari

Note:

I am using AEM repository for storing

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi Hari,

Try using the guideBirdge API here, maybe you can set the id returned from your service in a form hidden field and on guideBridge.submit success, you may just show the field value in the js alert. Below is an approach that I tried :

guideBridge.submit({

  validate: false,

   error : function (guideResultObject) {//log something

   },

  success : function (guideResultObject) {alert(hidden_id.value);

  location.href = "http://www.example.com/ThankYou.html";

  }});

API reference : Adaptive Forms Class: GuideBridge

Thanks,

Mayank

View solution in original post

6 Replies

Avatar

Employee Advisor

Hi Hari,

Do you want to display the data returned from the service in the form itself or you want to have it some new page like a Thank you Page?

Please share details on service, form structure and how the data is residing currently in the crx?

-Mayank Gandhi

Avatar

Level 10

Sounds like Prepopulating Form with Service data - do we have docs for this?

Avatar

Level 2

Hi Mayank,

Thanks for your reply..

On clicking of submit button from adaptive form-->A node will be created in the repository with unique ID-->The service will return the unique ID,which need to be displayed as "popup" to the user.

Service -

I am using sling.getservice to connect my service from post.POST.jsp

Form structure:      text field with submit button at the bottom

CRX: Form data are stored as individual node of type -->sling:folder

-Hari

Avatar

Correct answer by
Employee Advisor

Hi Hari,

Try using the guideBirdge API here, maybe you can set the id returned from your service in a form hidden field and on guideBridge.submit success, you may just show the field value in the js alert. Below is an approach that I tried :

guideBridge.submit({

  validate: false,

   error : function (guideResultObject) {//log something

   },

  success : function (guideResultObject) {alert(hidden_id.value);

  location.href = "http://www.example.com/ThankYou.html";

  }});

API reference : Adaptive Forms Class: GuideBridge

Thanks,

Mayank

Avatar

Employee Advisor

Hi Hari,

Any updates on this?