Expand my Community achievements bar.

SOLVED

Prefill service using FDM to fill the table

Avatar

Community Advisor

Trying to implement the use case mentioned in the document i.e. https://experienceleague.adobe.com/docs/experience-manager-learn/forms/prefill-fdm-db/introduction.h...

But I am not able to get the table prepopulated with the data.

shaileshbassi_0-1656439848757.png

I have followed the similar steps mentioned in the document. Below are the screenshots

shaileshbassi_1-1656439915695.png

shaileshbassi_4-1656440187882.png

 

shaileshbassi_3-1656440148180.png

shaileshbassi_5-1656440265762.png

shaileshbassi_7-1656440313047.png

 

When doing the "Test Model Object", it is showing me the result as present in the MySQL server

shaileshbassi_2-1656440070999.png

 

can anyone please help with any pointers, what could be missing over here to get the prefill of the form and its beneficiary table.

Thanks

 

1 Accepted Solution

Avatar

Correct answer by
Level 5

Then your form is not using the custom template (FDMDemo).
See https://experienceleague.adobe.com/docs/experience-manager-learn/forms/prefill-fdm-db/get-request-pa...

 

I am assuming you did not use the sample form, link on https://experienceleague.adobe.com/docs/experience-manager-learn/forms/prefill-fdm-db/create-adaptiv...

If you did, then check following:

- Form properties, Form Model is set to that which you created.

- Adaptive form container, Prefill Service is set to "Form Data Model Prefill service".

- All form fields are bound properly.

View solution in original post

9 Replies

Avatar

Employee

Hello  shaileshbassi,

 

I suggest you check the logs if any error is coming up or

 

you can also check at form properties whether it is pointing to the right FDM  model schema or not? 

 

Thanks,

 

Avatar

Community Advisor

There is only a warning message in the logs i.e.

28.06.2022 23:37:24.351 *WARN* [[0:0:0:0:0:0:0:1] [1656439643644] GET /content/dam/formsanddocuments/training/af-with-fdm-employee-association-beneficiary/jcr:content HTTP/1.1] org.apache.sling.models.impl.ModelAdapterFactory Could not adapt to model
org.apache.sling.models.factory.MissingElementsException: Could not inject all required fields into class com.adobe.fd.ccm.channels.web.impl.model.v1.WebChannelImpl
	at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:754) [org.apache.sling.models.impl:1.4.16]
	at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:428) [org.apache.sling.models.impl:1.4.16]
	at org.apache.sling.models.impl.ModelAdapterFactory.getAdapter(ModelAdapterFactory.java:270) [org.apache.sling.models.impl:1.4.16]
	at org.apache.sling.adapter.internal.AdapterManagerImpl.getAdapter(AdapterManagerImpl.java:143) [org.apache.sling.adapter:2.1.10]
	at org.apache.sling.api.adapter.SlingAdaptable.adaptTo(SlingAdaptable.java:104) [org.apache.sling.api:2.22.0]
	at org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource.adaptTo(JcrNodeResource.java:156) [org.apache.sling.jcr.resource:3.0.18]
	
	
Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject protected org.apache.sling.api.SlingHttpServletRequest com.adobe.fd.ccm.channels.web.impl.model.v1.WebChannelImpl.slingRequest
		at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:738) [org.apache.sling.models.impl:1.4.16]
		... 378 common frames omitted
	Caused by: org.apache.sling.models.factory.ModelClassException: Could not adapt from class org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource to interface org.apache.sling.api.SlingHttpServletRequest
		at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1064) [org.apache.sling.models.impl:1.4.16]
		at org.apache.sling.models.impl.ModelAdapterFactory.adaptIfNecessary(ModelAdapterFactory.java:1034) [org.apache.sling.models.impl:1.4.16]
		at org.apache.sling.models.impl.ModelAdapterFactory.setField(ModelAdapterFactory.java:977) [org.apache.sling.models.impl:1.4.16]
		at org.apache.sling.models.impl.ModelAdapterFactory.access$200(ModelAdapterFactory.java:115) [org.apache.sling.models.impl:1.4.16]
		at org.apache.sling.models.impl.ModelAdapterFactory$SetFieldCallback.inject(ModelAdapterFactory.java:475) [org.apache.sling.models.impl:1.4.16]
		at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:575) [org.apache.sling.models.impl:1.4.16]
		at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:733) [org.apache.sling.models.impl:1.4.16]
		... 378 common frames omitted

Thanks

Avatar

Level 5

As already mentioned check error.log for errors.

It's a little tricky tutorial to follow.

Are you seeing the following line in your stdout.log

Adobe !!!There is a empID parameter in the request 207



Avatar

Correct answer by
Level 5

Then your form is not using the custom template (FDMDemo).
See https://experienceleague.adobe.com/docs/experience-manager-learn/forms/prefill-fdm-db/get-request-pa...

 

I am assuming you did not use the sample form, link on https://experienceleague.adobe.com/docs/experience-manager-learn/forms/prefill-fdm-db/create-adaptiv...

If you did, then check following:

- Form properties, Form Model is set to that which you created.

- Adaptive form container, Prefill Service is set to "Form Data Model Prefill service".

- All form fields are bound properly.

Avatar

Community Advisor

@MorisMonk I have checked the above 3 points stated by you:

Point 1:

shaileshbassi_0-1656526744289.png

Point 2:

shaileshbassi_1-1656526815769.png

Point 3:

shaileshbassi_2-1656526860601.png

 

But still it is not working. Is there anything else which should be checked.

Thanks

 

 

Avatar

Level 5

Did you complete the steps on this page ?
https://experienceleague.adobe.com/docs/experience-manager-learn/forms/prefill-fdm-db/get-request-pa...

Your form needs to be using this template (FDMDemo).

Make sure you uncomment the following lines as mentioned on that page.

if(request.getParameter("empID")!=null) {
      System.out.println("Adobe !!!There is a empID parameter in the request "+request.getParameter("empID"));
      java.util.Map paraMap = new java.util.HashMap();
      paraMap.put("empID",request.getParameter("empID"));
      slingRequest.setAttribute("paramMap",paraMap);
    }

You can see this is where that log line is output (you are not seeing at the moment), as well as what is required to perform the get service on your FDM. All explained well enough on that page.

 

You can got to CRXDE Lite and check you current form.

Example, /content/forms/af/training/af-with-fdm-employee-association-beneficiary/jcr:content
Property cq:template should be /conf/global/settings/wcm/templates/fdmdemo
Property sling:resourceType should be fdmdemo/component/page/fdmdemo

 

 

Avatar

Community Advisor

Thanks @MorisMonk it worked. 

I have one doubt, earlier I was using the sling:resourceType fd/af/components/page2/aftemplatedpage

and now using the fdmdemo/component/page/fdmdemo.

So the nutshell is if we want to use the request parameter we need to set that in the "slingRequest" attribute as we are doing it in "/apps/fdmdemo/component/page/fdmdemo/fdmrequest.jsp". Is my understanding correct?

 

So, if I want to enter the text in the input field and based on that if I need to get the details, what should be done in that case?

 

Thanks