I am working on a form where client and spouse information is entered separately (Client A and Client B). I want to set up the form so that when a checkbox is selected the address information from Client A will automatically be entered in the corresponding fields for Client B. I haven't been able to get it to work. In this form, I'm not using the address field, each component is a single-line text field. See screenshot attached.
Question
Question
How to autofill fields with data from other fields when a checkbox is checked.
Replies
What have you tried? since they are each their own fields you should be able to use a formula in each of client B's fields. Something like "=ClientA_Address" or whatever the variables are for each of the fields.
Correct me if I'm wrong, Zac, but using a calculation for "if box checked, use Address A" would lead to problems if you tried free typing when the box isn't checked. Because if the "else" condition is an empty string, then various edits you could make would actually wipe out/override anything typed into the client B fields (at least, that was the behavior last time I tested it, but it's been a few years).
To overcome that, I think you would need 3 address fields. If the checkbox is unchecked, show the existing Client B. If it is checked, show a Client C field (which could be labeled as Client B but would be a separate field/variable). Then client C could be read-only and have formulas for "if checked use client A value, else use client B value". That way C would have values in either case and could be used behind the scenes if pushing this data into another system.
You are correct, if you ever go back to edit Client A address with the checkbox unchecked it would wipe Client B.
Having three fields is a worthwhile workaround if the user requires physically seeing the two different address fields are the same. Most times I've used this option I just don't display the second set of address fields and use client A in my integrations/workflow when the use same checkbox is checked.
In which case I would move the checkbox between client A and B's addresses and hide the fields when the option is checked.
I tried a few things I found online, but none seem to work. Most recently, I was trying an if, else formula. To try and get it to populate the info for client B only if the box was checked. If the box is unchecked then it would leave it open to fill in with different information than Client A. Because the input into this field is merging into a word document, I really want to keep it as single field. I hope that makes sense.