SOLVED

Re: Field behaviour on a form - if checked map to a field as false

Go to solution
adele_briggs
Level 3

Field behaviour on a form - if checked map to a field as false

I am in the process of adding a check box to a form. However the behaviour of the check box I would like is the opposite to what the field is capturing.

 

example

Please tick the box if you don't want to receive news, updates or product information from MHR International

example: if New check box = true, mapped to an opt in field = false.

 

Is this possible, or do I need to map to a separate field to first map to the opt out, and then have a trigger which will control if the opt in field is true or false?

 

Thanks

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
Dave_Roberts
Level 10

Re: Field behaviour on a form - if checked map to a field as false

Hey Adele,

 

You might try using the "checkboxes" field type instead of the "checkbox" field type on your form. The checkboxes field type allows you to enter 2 bits of information:
1) Display Value -- this is the text to the right of the input

2) Stored Value -- this is the value that gets stored on the record

 

Once you setup a new checkboxes field, you can select the "Values" link in the right column of the editor to adjust both what the user sees and what gets sent back to the server. This sounds like you a situation where you'd want to add:

1) Please tick the box if you don't want to receive news, updates or product information from MHR International to the Display Value
2) No to the Stored Value

 

I just posted a walk-thru for changing a "checkbox" field to a "checkboxes" field on another post here: https://nation.marketo.com/t5/product-discussions/make-label-wrap-with-two-column-checkboxes/td-p/31... and there's some screenshots there of where/how to update the Display Value and the Stored Value for a "checkboxes" field. 

 

Let me know if you've got any questions on how this gets setup, I'd be happy to help -- or if you were able to get this working for anyone else who might run into a similar issue in the future.

 

Thanks,
Dave

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Field behaviour on a form - if checked map to a field as false

Sorry for the delay, I’m writing a very long blog post explaining the whys and hows of code, but you can jump to get it here:

 

MktoForms2 :: Invert Submitted Checkbox Value

https://codepen.io/figureone/pen/mdWdBaY?editors=0010

 

Just put whatever field(s) you want to have this behavior in the invertibleCheckboxNames array. (Use their form field names, a.k.a. their SOAP API names — not REST.)

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Field behaviour on a form - if checked map to a field as false

14 REPLIES 14
Dave_Roberts
Level 10

Re: Field behaviour on a form - if checked map to a field as false

Hey Adele,

 

You might try using the "checkboxes" field type instead of the "checkbox" field type on your form. The checkboxes field type allows you to enter 2 bits of information:
1) Display Value -- this is the text to the right of the input

2) Stored Value -- this is the value that gets stored on the record

 

Once you setup a new checkboxes field, you can select the "Values" link in the right column of the editor to adjust both what the user sees and what gets sent back to the server. This sounds like you a situation where you'd want to add:

1) Please tick the box if you don't want to receive news, updates or product information from MHR International to the Display Value
2) No to the Stored Value

 

I just posted a walk-thru for changing a "checkbox" field to a "checkboxes" field on another post here: https://nation.marketo.com/t5/product-discussions/make-label-wrap-with-two-column-checkboxes/td-p/31... and there's some screenshots there of where/how to update the Display Value and the Stored Value for a "checkboxes" field. 

 

Let me know if you've got any questions on how this gets setup, I'd be happy to help -- or if you were able to get this working for anyone else who might run into a similar issue in the future.

 

Thanks,
Dave

adele_briggs
Level 3

Re: Field behaviour on a form - if checked map to a field as false

Ahhh Amazing 😊 

 

I am going to have a run through of this now. I have used the check box for yes and no, but didn't realise I could use with only one.

If this works it will save so much.

I shall pop back in if I get stuck 😁

 

thank you so much for such a quick response.

adele_briggs
Level 3

Re: Field behaviour on a form - if checked map to a field as false

I managed to set this up and it works exactly as I wanted it to.  Thank you.

adele_briggs
Level 3

Re: Field behaviour on a form - if checked map to a field as false

I might need a rethink, or some more guidance if I haven't set up correctly. 😫

 

when I've subsequently run some more tests it isn't saving exactly as I wanted it to.

 

When the box is checked it records the field as NO / False

When the box is left unchecked it clears the value from the field and this needs to be YES / True

 

I have other flows that set unsubscribed based on the True/False status of this field and this is not being triggered.

I don't seem to get a Changed Data Value when the field changes, I don't know if this is controlling the flows for my Unsubscribed

 

Any advice is greatly appreciated, I thought I'd cracked it.

SanfordWhiteman
Level 10 - Community Moderator

Re: Field behaviour on a form - if checked map to a field as false


When the box is left unchecked it clears the value from the field and this needs to be YES / True

(To be clear to other readers, a Checkboxes set with no checked boxes doesn’t “clear” the field value in Marketo but rather doesn’t change the value.)

 

You‘re right that a Checkboxes set with its one checkbox left unchecked can’t send “yes” to Marketo (= Boolean true). The box if checked can send “no”. But not the reverse.

 

To invert a checkbox value completely — so checked sends “no” and unchecked sends “yes” — you want to go back to a standard Checkbox (not Checkboxes) and add a few lines of JS. I’ll post that solution on the blog on Sunday.

adele_briggs
Level 3

Re: Field behaviour on a form - if checked map to a field as false

Thank you for clarifying. I'll look out for the solution. I've never needed to add in any JS so hopefully I'll be able to do that 😆.

 

 

adele_briggs
Level 3

Re: Field behaviour on a form - if checked map to a field as false

I don't know if I'm looking in the right place, but haven't seen any details on the JS. Any help is really appreciated. Thanks Adele.

SanfordWhiteman
Level 10 - Community Moderator

Re: Field behaviour on a form - if checked map to a field as false

Sorry for the delay, I’m writing a very long blog post explaining the whys and hows of code, but you can jump to get it here:

 

MktoForms2 :: Invert Submitted Checkbox Value

https://codepen.io/figureone/pen/mdWdBaY?editors=0010

 

Just put whatever field(s) you want to have this behavior in the invertibleCheckboxNames array. (Use their form field names, a.k.a. their SOAP API names — not REST.)

adele_briggs
Level 3

Re: Field behaviour on a form - if checked map to a field as false

Thank you so much, and thank you for taking the time to update me, it is appreciated. 😁