Passing values from one form to another

Jared_Langdon

01-08-2018

I need to present a Form B to the user after he submits Form A.  Form B needs to be prefilled with data based on values entered by the user in Form A.  I know how to set up a custom submit service.  I know how to specify Form B as the redirect for Form A so that it appears after a successful submit.  I also know how to set up a custom prefill for Form B.  What I can't seem to do is pass anything from Form A's submit service to the prefill service for Form B.  I must be missing something obvious, but I've searched high and low with no success.

In the prefill service I have access to DataXMLOptions.  From there I can get a user ID, but that's not useful because these may be anonymous users.  Is there anything that I can set in my submit service that I can access through DataXMLOptions (e.g. a session ID)?  If so, I could stage what I need in a file or a database during the submit service and retrieve it again in the prefill service.  I just don't see any way of doing that.

Any help is greatly appreciated.  Thanks.

View Entire Topic

lesutton1

02-08-2018

In the template that does the actual render of the form, you can populate the "data" variable that will be pushed into the form. To get variables and parameters, the most useful gets are from the properties object and the request object. To get a parameter passed by a form or URL, you can use "getParameter" on the request object.

For example:

String title = properties.get("jcr:title", "default title");
String text = properties.get("jcr:text", "default text");

String employeeID = request.getParameter("employeeID");
String entryType = request.getParameter("entryType");

<%

           String dataXML="<afData>" +

                            "<afUnboundData>" +

                                "<dataRoot>" +

                                    "<first_name>"+ "Tyler" + "</first_name>" +

                                    "<last_name>"+ "Durden " + "</last_name>" +

                                    "<id>"+ employeeID + "</id>" +

                                    "</dataRoot>" +

                            "</afUnboundData>" +

                        "</afData>";

        slingRequest.setAttribute("data", dataXML);

%>