Problem hiding a form based on Airtable field value

I am trying to HIDE an event RSVP form (“rsvp-form”) on a page when the value of Airtable field “Eventstatus” = “Full”.

I have followed the scripts shared in a couple of topics like this one.

Here is my code entered into the Custom Footer Code.

<script>    
    document.addEventListener("DOMContentLoaded", function() {    
        var waitForData = setInterval(function () {
            if (typeof $ != 'undefined') {
                const recordId = getUrlParam('recordId');
                if (window.records && window.records[recordId] && window.records[recordId].record.fields['Eventstatus'] === 'Full') {
                    
                    var form = document.getElementById('rsvp-form');
                    form.style.display = 'none';

                    clearInterval(waitForData);
                }
            }
        }, 100);

        function getUrlParam(name) {
            const url = new URL(window.location.href);
            let param;
            for(var key of url.searchParams.keys()) {
                if(key.toLowerCase() === name.toLowerCase()) {
                param = url.searchParams.get(name);
                break;
                }
            }
        
            if(!param && name.toLowerCase() === 'recordid') {
                param = getRecordIdFromPath();
            }
            return param;
        }
        
        function getRecordIdFromPath() {
            let pathName = window.location.pathname;
            if (pathName.indexOf('/r/rec') !== -1) {
                pathName = pathName.substr(pathName.indexOf('/r/rec') + 3);
                if (pathName.indexOf("/") !== -1) {
                pathName = pathName(0, pathName.indexOf('/'))
                }
                return pathName;
            }
            return undefined;
        }
    });
</script>

The field ‘Eventstatus’ is displayed on the page in a List Details Block. Yet the form is not hidden when ‘Eventstatus’ = “Full”.

Have I added the code incorrectly? Are there alternatives for hiding a form based on Airtable field values?

@AndrewJ I think if you can wait a week then this will come as a feature in the platform :slight_smile:

4 Likes

Excellent. Thanks for responding @artur.

:eyes: Following

@artur great news! Will it be released this week still you believe?

Could be tomorrow or early next week… we are doing some final checks

1 Like

Hey folks can you pls check it ? It’s been released

Hi @artur. I can see the new visibility options in Forms allowing us to “Hide block if…”. But I cannot get this to work correctly. Form still displays event through ‘EventStatus’ field = “Full”. I have tried several other conditions.

@AndrewJ can you pls share the app in our support chat so we can check it ?