SOLVED

Conditionally load input field based on database entry

Go to solution
Highlighted

Conditionally load input field based on database entry

Hello everyone,

Goal : I have a form with a checkbox that asks permission to store the user's data. If they have selected 'yes' I don't want to show the checkbox on future forms or page visits.

What I've tried:

1. Check if there is a munchkin cookie in the users browser.

2. If there is, make an API call to the lead db to check the value of the db field 'Consent_to_Processing__c'.

3. The input row is hidden with CSS, but if the API call returns 'false' or 'null', then the input row will be displayed.

Current problems I'm trying to solve for:

1. Can I conditionally load the input based on the API call value?

2. I'm trying to not have to load the form with JS because I don't our Automation team to be able to embed different forms without having to get the JS file updated.

3. There are timing problems currently with the form sometimes loading after the API call is finished, so the DOM element to unhide doesn't exist when the API value is checked.

Any help from the community would be very helpful. Thanks.

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 10 - Community Moderator

Re: Conditionally load input field based on database entry

While better as it doesn't leak your credentials, that's a Denial of Service vector against all of your API integrations.  (I could use all your calls in less than an hour.)

The API is not designed to be used in response to untrusted, let alone anonymous, user activity.

Everything you need is built into the Forms 2.0 Progressive Profiling feature. A Checkbox field that's moved into the ProgPro fieldset will be shown as long as it's unchecked/false. When true it will be considered filled and will not be shown.

View solution in original post

6 REPLIES 6
Highlighted
Level 10 - Champion Alumni

Re: Conditionally load input field based on database entry

So you want to use Progressive Forms? There are docs.marketo.com on this.

Unless this is a custom Form that lives off Marketo?

Sanford Whiteman

Highlighted

Re: Conditionally load input field based on database entry

Some of the forms will live off of Marketo, some of them will live on Marketo landing pages.

Highlighted
Level 10 - Community Moderator

Re: Conditionally load input field based on database entry

You must not use the API for this, period, but please tell me you're not exposing REST creds in the browser because you need to stop that before we continue.

Highlighted

Re: Conditionally load input field based on database entry

The REST creds aren't in the browser. There is an ajax call to a server-side proxy written in PHP.

Highlighted
Level 10 - Community Moderator

Re: Conditionally load input field based on database entry

While better as it doesn't leak your credentials, that's a Denial of Service vector against all of your API integrations.  (I could use all your calls in less than an hour.)

The API is not designed to be used in response to untrusted, let alone anonymous, user activity.

Everything you need is built into the Forms 2.0 Progressive Profiling feature. A Checkbox field that's moved into the ProgPro fieldset will be shown as long as it's unchecked/false. When true it will be considered filled and will not be shown.

View solution in original post

Highlighted

Re: Conditionally load input field based on database entry

Sanford,

Thank you for the answer. I will switch over to Progressive Profiling.