Apr 26, 2019 05:21 PM
Saw the URL structure for prefilling a form (airtable[dot]com/1234?prefill_Name=Jane for example), but I’m trying to prefill a form with today’s date in one of the date fields.
I tried ?prefill_Date=TODAY() and ?prefill_Date=Now() but appears after some experimentation that URL passes the text straight through rather than using the named formula.
Is there any way to get a date field on a form to pre-fill / default to today’s date??
Apr 26, 2019 07:23 PM
If your link is generated by a formula within your base, you could achieve this like this:
"https://airtable.com/formviewidhere?prefill_Todays%20Date=" & TODAY()
Alternatively, you could use the Created Time field type if you’re just trying to track when a record was submitted. I don’t believe it shows up on the actual form, but you can see it in the grid view.
Apr 26, 2019 10:08 PM
Thanks!
Unfortunately neither of those cases quite fit.
The date needs to be entered - 95% of time it will be today’s date, but the person submitting needs to be able to adjust it.
And I want the form link to be bookmarked by users …clicking the link should bring up the form with today’s date as default…
Any other thoughts?
Apr 27, 2019 07:04 AM
Hmm… I can only really think of a few things, but none are perfect and two assume that you have some sort of website for your users; or just a landing page.
Rather than having them bookmark the link itself, you could have them bookmark a shared view with just the link to the form.
Or, if you do have a site to embed it on, you could embed that view with the link to click.
Lastly, similar to the post linked below, if you do have a website and can edit the source code, you may be able to embed it into the URL there.
Wish I could help more! If you do get it figured out, definitely let me know.
Apr 20, 2020 01:23 PM
This was a while ago, but I thought I’d share my workaround.
My workaround was to have two/three different fields. On the form itself, I have a “Timestamp Override” that allows the date/time to be chosen manually. If left blank, no problem.
On the “backend” the database has a Timestamp field that first looks to see if the override field is filled in and uses that. If the override is left blank, it uses the CREATED_TIME() function and pulls the timestamp when the record was created.
Sep 10, 2020 09:38 AM
What I would do is 3 cells :
So you can use the cell 3 for the definitive date
Sep 21, 2020 05:05 PM
We’ve built a form that integrates with Airtable. One of its features is the ability to auto-fill today’s date when the user initially load the form.
Mar 16, 2021 03:45 AM
Something I’ve cobbled together from other places. If you can lead your user to a HTML page and click a link, then that link can include the TODAY prefill snippet via JavaScript as follows:
<!DOCTYPE html>
<html>
<head>
<title>Prefill today link</title>
<script>
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
var today = dd + '/' + mm + '/' + yyyy;
</script>
</head>
<body>
<script>
document.write('<a href="https://airtable.com/FormIDhere?prefill_Date=' + today + '">Link</a>');
</script>
</body>
</html>
Source for some of this gratefully acknowledged below:
Jan 03, 2023 09:08 AM
You can create a javascript bookmarklet. So when you click on it it will execute a bit of javascript. You create the bookmark like so:
With javascript, we can generate the current date and then navigate the browser. So for the bookmark URL, put in the following:
javascript:(() => { window.location.href = `https://airtable.com/<FORMID>?prefill_Datetime=${encodeURIComponent(new Date().toLocaleString().replace(',', ''))}`; })();
Then, this will generate the date and then navigate the browser for you.
Jan 03, 2023 09:11 AM
Crud, the forum is escaping some of the code snippet there. Replace ":" with the actual colon ":" when creating your bookmark.