Hi
Is there and way to pre-fill form 2 data on the basis of data submitted on form 1 .
iam using dynamics 365 marketing forms and landing pages . I have to forms and 2 landing pages. I want form 2 prefill on the basis of data submitted on form 1 .
Thanks
Fariha Asmat
Hi Fariha,
You can save data of form 1 to localStorage property at formSubmit event.
Because each input field has a specifc id attribute, hence we can get its value with document.getElementById("123").value method.
Script 1:
MsCrmMkt.MsCrmFormLoader.on('formSubmit', function (event) { var firstName = document.getElementById("3f746946-34b4-442c-a677-e232cdd2bc40").value; var lastName = document.getElementById("xxxx").value; var emailAddress = document.getElementById("yyyy").value; localStorage.setItem("firstname", firstName); localStorage.setItem("lastname", lastName); localStorage.setItem("emailaddress", emailAddress); });
Then on the second landing page, get items from localStorage to fill fields of form 2.
Script 2:
MsCrmMkt.MsCrmFormLoader.on('afterFormRender', function (event) { var firstName = document.getElementById("c98e6449-2f57-4058-aeee-546b0af11b5a"); var lastName = document.getElementById("aaa"); var emailAddress = document.getElementById("bbb"); firstName.value = localStorage.getItem("firstname"); lastName.value = localStorage.getItem("lastname"); emailAddress.value = localStorage.getItem("emailaddress"); });
Please refer to following articles for how to use marketing form API and localStorage property:
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
Regards,
Clofly
André Arnaud de Cal...
291,969
Super User 2025 Season 1
Martin Dráb
230,842
Most Valuable Professional
nmaenpaa
101,156