12 Replies Latest reply on Apr 30, 2018 1:37 AM by Sanford Whiteman

    Form Prefill Identity Mismatch

    Pamela Hudadoff

      I am building a two step communication preferences solution to ensure that the communication preferences loaded are for the correct Marketo identity.   (We have a system where individuals might have multiple identities - email addresses.)


      The first step is an email only form with prefill enabled.    When this is submitted, it takes the user to the preferences setting page.  Simple enough.   Then I tested the form.


      Test 1 on Windows 10, Firefox 56.0 (64 bit) - but this also happens on MS Edge :

      I come to the email only page (http://info.bstock.com/Communication-Preferences-Get-Email.html) and it is prefilled with my last cookied identity - pamtest8@apm.com

      I alter the email address from pamtest8 to pamtest80@apm.com and submit the form.


      !! Here is the issue:

      The preferences page comes up with a mix of my new email address - pamtest80 and values prefilled from my pamtest8 cookied identity.   When I look at the page source for the page, the prefill variable shows the values for the new identity (all of the fields are pretty much empty).


      Where is the form getting the original pamtest8 values that are populated there when the prefill variable isn't showing them there?

      More importantly, how can I stop this from happening?   The whole purpose of the two form solution is getting the right identity in place in the cookie so that the preferences form will fill accurately.


      One more thing to know:

      For the email only form, I have some custom javascript code that takes a encrypted URL parameter, decrypts it, and uses the value to fill the email address field.   It is set up so that if there is a cookie, it will overwrite the email address from the cookie.  However, in this situation, the code in the javascript that does this should not be executing (no URL parameter).


      Any and all wisdom are welcome.

        • Re: Form Prefill Identity Mismatch
          Sanford Whiteman

          The cause of this behavior is clear, but unfortunately a solution isn't.


          The reason you see mixed data at first is that the cookie is not associated in real-time. (There's never a guarantee that a re/association will be complete by the very next HTTP request.)


          As a result, you see the existing association's fields for everything that wasn't on the first form. Only the email address was on the first form, and it is immediately available because it's keyed on the aliId (which can be thought of as a form payload cache).


          If you refresh the page after a second or so, the association will be complete (although it's still not guaranteed, a couple seconds of delay will cover most cases).


          The only way to ensure you never see mixed values is if you strip off the aliId (you can do this in the onSuccess on the first form) and then poll the second page every second and refresh if the PreFill values don't match the new email (which you can pass in the URL).


          Also, your URL-based form fill should be changed to use the forms API setValues() method. Setting element values directly is not guaranteed to work, and the object model has its own accessors for that reason.

          1 of 1 people found this helpful