AEM form with url parameter | Community
Skip to main content
New Participant
July 26, 2023
Solved

AEM form with url parameter

  • July 26, 2023
  • 3 replies
  • 1187 views

Hello,

 

Could someone provide me input as what could be the best way to store the URL parameters and how to do it.

 

I have 2 forms.  [FORM1 and FORM2]

1>When we hit the 1st  AEM FORM1 with URL parameter say ?key=value 

Then we need to pass this key and its value to FORM2 through a URL redirection. What will be the best way to pass this key from Form 1 to Form2. This key will be needed to be submitted on submit of FORM2.

 

2>We will also need to remove this stored key and its value after form submit on Form2 .so that we are  ready to take up new key and value incase user hits again Form1.

 

Please suggest how could I store the param keys which could be used across FORM1 and FORM2

 

Any code samples on this will be helpful.

 

Regards,

Srinivas

 

Regards,

Srinivas

 

 

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

@srinivas_opti :

 

If i understand clearly , assuming you are using adaptive forms,

 

form1 : http://localhost:4502/content/forms/en/home.html?key=123

form2: http://localhost:4502/content/forms/en/index.html

 

You want to pass the key=123 from form 1 to form 2 .

 

In the form1 submit or continue button -> select the click event -> write the js to read the query parameters key and value and append to redirection url at the form1.

 

form 1 -> submit or continue button-> hyperlink should be-> http://localhost:4502/content/forms/en/index.html?key=123query parameter can be assigned from the javascript.

 

so that in the form2 , you can utilize the query parameter . 

 

Otherwise , 

If form 1 and form2 both are going to submit in the one transaction, you can utilize the session storage to store the paramter and you can retrieve when required and delete the same after form2 submissin done.

 

sessionStorage.setItem("key","134"); '// To set the session storage value in browser

sessionStorage.getItem("key");// To get the value from the session storage.

 

 

Thanks, 

Siva

 

 

 

 

 

3 replies

SivakumarKanoori
SivakumarKanooriAccepted solution
New Participant
July 27, 2023

@srinivas_opti :

 

If i understand clearly , assuming you are using adaptive forms,

 

form1 : http://localhost:4502/content/forms/en/home.html?key=123

form2: http://localhost:4502/content/forms/en/index.html

 

You want to pass the key=123 from form 1 to form 2 .

 

In the form1 submit or continue button -> select the click event -> write the js to read the query parameters key and value and append to redirection url at the form1.

 

form 1 -> submit or continue button-> hyperlink should be-> http://localhost:4502/content/forms/en/index.html?key=123query parameter can be assigned from the javascript.

 

so that in the form2 , you can utilize the query parameter . 

 

Otherwise , 

If form 1 and form2 both are going to submit in the one transaction, you can utilize the session storage to store the paramter and you can retrieve when required and delete the same after form2 submissin done.

 

sessionStorage.setItem("key","134"); '// To set the session storage value in browser

sessionStorage.getItem("key");// To get the value from the session storage.

 

 

Thanks, 

Siva

 

 

 

 

 

Thanks,Siva
New Participant
July 27, 2023

Can you please  explain the use case a little more ?

New Participant
July 26, 2023

Any inputs from anyone as how could I proceed with this??