Hi all,
We have observed a quite annoying behaviour on the forms API when you combine it with some visibility rules.
A form contains an Opt-in field (Name BEU_SOI) and an OptIN Date field (Named BEU_SOI_DateTime). The BEU_SOI Field has a visibility rule and is controlled by the BEU_SOI_DateTime field: BEU_SOI only shows if BEU_SOI_DateTime is empty.
That Forms also has a script that handles some information directly in the form. Namely, if the BEU_SOI is checked, BEU_SOI_DateTime is filled with the current datetime. What is really weird is that in this case, the BEU_SOI is simply removed from the values sent to Marketo! It seems to be related to the visibility rule as if we remove the visibility rule, the problem disappears.
Test it here: https://m.konicaminolta.co.uk/SOI-tests.html?aliId=50831173
Is this a bug or an expected behavior ? If the later is true, what am I missing ?
Thx for your help
-Greg
Justin Cooperman Sanford Whiteman
Solved! Go to Solution.
Check this demo and pay very close attention to the order of operations:
MktoForms2 :: Set VR-hidden Field
Network trace:
Yes, this is expected behavior -- at least once you settle on a working definition of how Visibility Rules work.
A call to setValues() triggers VRs -- which is a good thing -- even if it's done in an onSubmit listener. (Remember, a given listener doesn't know if it's the last listener in a stack of listeners, so it may not be past the point of user interaction, i.e. if a later listener sets the form to submittable(no) then the form remains usable.)
So you're removing the checkbox from the form entirely when setting the date.
To compensate for this, set the checkbox value with addHiddenFields, not setValues. (I don't recommend using the alias vals as it obscures this important difference.)
Hi Sanford,
Thx for looking into it.
I tried with addHiddenfFields before, with the same result Then I tried with the setValues with the hope that it would change something, but...
-Greg
Are you sure you had the timing right with addHiddenFields? Your code is on that page is... rather verbose. Could use some refactoring before you debug this particular issue.
Check this demo and pay very close attention to the order of operations:
MktoForms2 :: Set VR-hidden Field
Network trace:
Hi again Sandy,
Thx for the hint about the order of operations. The fixed it!
-Greg