Expand my Community achievements bar.

SOLVED

Prefill Adaptive Form when calling from External Application

Avatar

Level 2

Hello Experts,

I was wondering if anyone can help me with a query. 

I have a requirement where I need to call (invoke) an Adaptive Form from an External Application. When Adaptive Forms gets rendered, it needs to have some prefilled data. 

Here's the flow- 

1. There will be links to Adaptive Forms in the External application

2. When user clicks on the link, a backend service will be called to create prefill XML. 

3. I need to be able to pass this prefill XML to the Adaptive Forms (when it renders) as section visibility depends on the XML. 

 

How can I achieve this? I read this article (https://helpx.adobe.com/aem-forms/6-2/prepopulate-adaptive-form-fields.html) and it talks about using the HTTP protocol OR a prefill service. But I dont know if they will be useful in my scenario.

I am using AEM Forms 6.2 (OSGi). Is there an API call that the external application can make to invoke Adaptive forms with data? Or is there a way I can have external application make a post call to an AEM Sling Servlet and return an Adaptive form as response? What are my options here? 

 

Thank you so much for your help ! 

Thanks,

Priyank

1 Accepted Solution

Avatar

Correct answer by
Level 2

Update:

Here's how I ended up implementing the solution. I dropped the idea of using HTTP protocol for prefilling Adaptive Form, because it did not support authentication. 

I ended up creating a custom template and prefilled the XML by setting data attribute it slingRequest. 

View solution in original post

3 Replies

Avatar

Level 2

Hi,

It depends on how you are getting your prefill XML. If, you are saving this XML in your file system, please use file:// protocol. If you can ensure saving it in crx, do use, CRX protocol. Same goes for http:// protocol, if you can specify the HTTP location of the XML. You can do this, when you are embedding your adaptive form url within links, just extend them to these protocols and use the extended url.

I get a feeling, that "Setting data attribute in slingRequest" this would be most useful to you. After you create your prefill XML, add this XML string to attribute "data" of the request responsible of calling the adaptive form. This will prefill your form to the data you need.

Avatar

Level 2

asomani wrote...

Hi,

It depends on how you are getting your prefill XML. If, you are saving this XML in your file system, please use file:// protocol. If you can ensure saving it in crx, do use, CRX protocol. Same goes for http:// protocol, if you can specify the HTTP location of the XML. You can do this, when you are embedding your adaptive form url within links, just extend them to these protocols and use the extended url.

I get a feeling, that "Setting data attribute in slingRequest" this would be most useful to you. After you create your prefill XML, add this XML string to attribute "data" of the request responsible of calling the adaptive form. This will prefill your form to the data you need.

 

Thank you. I am trying to use the HTTP protocol. But the problem is it is not accepting authentication parameters. I am already logged into an AEM session, and using dataRef =<an AEM Get Service>, but it does not populate any data. If I remove authentication requirements for that servlet, it works fine. 

Is there a way you know where we can achieve this without keeping the servlet anonymous ?

Avatar

Correct answer by
Level 2

Update:

Here's how I ended up implementing the solution. I dropped the idea of using HTTP protocol for prefilling Adaptive Form, because it did not support authentication. 

I ended up creating a custom template and prefilled the XML by setting data attribute it slingRequest.