Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

AEM form with url parameter

Avatar

Level 3

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

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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

View solution in original post

3 Replies

Avatar

Level 3

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

Avatar

Level 9

Can you please  explain the use case a little more ?

Avatar

Correct answer by
Community Advisor

@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