Any way to prefill form fields?

I would like to use a form to validate a user’s email address.

Essentially, I just need to know whether they have clicked a certain link, but there’s no easy way (that I know of) to do that within Coda.

To circumvent that limitation, after my users submit their email address and form I could send them an email with a second form that they have to submit. If there were a way for me to track which user received which form link this would be easy. But I don’t know how to do that.

Perhaps one solution would be if there were a way to pre-fill form fields with special urls, e.g.
https://coda.io/form/Untitled-Form_d-K7PSeO9qx/#Special%20Code=12345

This would prefill the column Special Code with 12345, this way when the user submits this form I can easily tell who has validated their email.


Alternatives:

  1. I can force users to log in to Coda, but in some cases I think they may not want to do this.
  2. I can ask users to manually input their special code, but this is not very user friendly.

It’s a bit elaborate but you could do it with the API. Easiest is to use Google Apps Script.

Your doc would be something like this:

And then for the API part, check out the Getting Started Guide for how to generate an API key and set up a Google Apps Script, and then your Google Apps Script code would be something like this:

// Set up Coda info
CodaAPI.authenticate('<<yourAPIKeyHere>>');
var DOC_ID = '<<theIdOfYourDocHere>>';
var TABLE_ID = '<<theIdOfYourTableHere>>';
var COLUMN_ID = '<<idOfEmailValidatedCheckboxColumnHere>>';

// This function runs when someone visits the public script URL
function doGet(q) {

    // Grab the rowId from the custom URL we sent the person to
    var rowId = q.parameters.rowId;

    // Log the validation in Coda
    CodaAPI.updateRow(DOC_ID, TABLE_ID, rowId, {COLUMN_ID: "true"});

    // Show success message
    return  HtmlService.createHtmlOutput('<html><body>Thank you for validating!</body></html>');
}

Not sure your experience level with this kind of thing, and whether the above sounds super easy or hopelessly daunting, but the API can be pretty handy for little extra pieces of functionality like this! Happy to help if you feel like giving it a try.

Ooh, that’s very cool. I’ll look into it.

1 Like

This is now a native feature by the way:

1 Like