How to pass logged-in user data to embedded form

If the embedded form supports passing data by url then one can use a code similar to this one to pass currently logged in user info to the form:

<script>
    let tallyUrl = 'https://tally.so/embed/urlHash?hideTitle=1&alignLeft=1';

    if(window['logged_in_user'] && window['logged_in_user']['airtable_record_id']) {
        tallyUrl = tallyUrl + '&record_id=' + window['logged_in_user']['airtable_record_id'];
    }
 
    document.write('<iframe src="' + tallyUrl + '" width="100%" height="500" frameborder="0" marginheight="0" marginwidth="0" title="My Application"></iframe>');
</script>

Please note that the above code it supposed to work within custom code block.

3 Likes

Thanks for the tips.

I notice it’s possible to get all the fields of the Airtable users (linked to Softr users) .
Exemple to get the field subName
window['logged_in_user']['subName']

Hi Jerome we expose so you can pass it as hidden parameters.

Thank you Artur for this Code.
Would it possible for you to explain how to use/implement it?
Thank you in advance!

Dear @Amaury,

You will need to add this to Custom Code block.

Let me know if you have more questions.

Hi Artur, Suzie
I want to prefill a form of Cognito Forms with the record ID ( {URL_PARAM:recordId} ) on list details block. The page will have a little form included.
I tried with the methods that you explain above, and also with an example with Jotforms and did not work for Cognito Forms.

The URL used for Cognito Forms to prefill, has this structure:
http://mysite.com/contactus?entry={“PostalCode”:“90210”,“Country”:“United States”,“RecordID”:“recXXXXXXXXX”}

For this example, the form include the field Postal Code, Country and RecordID.

It is possible some script to pass {URL_PARAM:recordId} to the form?

1 Like

@pinillo can you pls share the full code you used in your page ?

Hi Artur, thanks for your fast reply

Below an example code of the Cognito form. My idea is populate the Agent field(with {LOGGED_IN_USER:NAME}) and RecordID field ({URL_PARAM:recordId})

In Cognito forms, I can prefill the fields statically with the code below:

If the prefill is using the URL format, then use ?entry= as I share in the previous post

Thanks in advance!