Re: Can't read code

2239 0
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

Hi all

I only know basic HTML so the Functions field in Airtable to me looks like hieroglyphics.

In my events company, we require people to complete forms to update their existing data. I followed this tutorial: "Use a form to update an existing record" - and got the 2 tables working with automation.

However - if I want to apply this method to other bases, I'm worried because I don't understand the purpose of any of the code I've written. Can someone explain what is happening/the purpose of the following (broken down to baby level please eg. what does '' do in the code? what about &?):

Happy to read material if anyone wants to point me to any resources. Thank you.
6 Replies 6
7 - App Architect
7 - App Architect


Here's a little breakdown for you;

- Anything in quotation marks (double or single, doesn't matter) means treat everything inside as a 'string'. A string is just plain text. In other words, by wrapping text in quotation marks, you're telling the computer that this is just a string and not code.

- The ampersand, &, means join two strings together - the string on the left of the ampersand should be immediately followed by the string on the right. e.g. 'Hello' & 'World' would give you HelloWorld. Notice it doesn't automatically add a space for you, just sticks the two strings together.

- The reason you need to use the &, instead of just writing 'HelloWorld' is because you might want to include text that you don't know yet. For example, the RECORD_ID() part of your code is a special instruction that says give me the unique string that identifies this record.  You don't know what that string will be ahead of time so you can use the & to join the output of that instruction to some text that will be the same every time.

- The final bit of info you need to understand your code is the instruction ENCODE_URL_COMPONENT(Name). URLs or web addresses, need to be formatted in a particular way in order to work properly. For instance a URL can't contain a space, instead it is represented by %20. ENCODE_URL_COMPONENT is a function that takes a string and changes all the bits that need to be changed (like spaces) so that it will work as a URL. The function needs to be given an input before it can create an output, that goes in the parentheses (INPUT). In the case of your code it is using the Name field of the current record as its input.

To apply this to your code I'll show you a chunk of code and then the explanation in square brackets [];

'' [a string] & [join with] '?prefill_Guest%20ID=' [another string] & [join with] RECORD_ID() [this record's unique ID string] & [join with] '&prefill_Guest%20Name=' [another string, notice there's an & in this string so it's not performing its function of joining, it's just a piece of text] & [join with] ENCODE_URL_COMPONENT(Name) [take the Name field for this record and make it safe to use in a URL] & [join with] '&hide_Guest%20ID=true' [the last string]

Hope that helps, let me know if you want anything clarified.

Thank you so much! What a great explanation! I've just a couple of additional questions if that's alright:

1) '?prefill_Guest%20ID=' [another string]   - What does the ? mean here?

2) '&prefill_Guest%20Name=' [another string, notice there's an & in this string so it's not performing its function of joining, it's just a piece of text]  - If that's the case, and the & isn't joining 2 strings - what is the purpose of this &?

3) Could you clarify 'strings'? They are text - but actually have a function? eg. '&hide_Guest%20ID=true' . It's text because it's in 'quotations... but not ordinary text. It actually has a function of hiding the Guest ID field in the form...?

Many thanks for your help 🙂

7 - App Architect
7 - App Architect

You're right to be confused. What you're dealing with here is one system (Airtable's formula field), creating instructions for another system (URL parameters), that can be used to provide information to a third system (Airtable forms). I only really covered one of these systems, the Airtable formula field. I think the best way to answer your questions is to explain why these systems are being used in the first place.

You could get the same outcome for your data by sending everyone the same form with a name field, collecting their responses and then manually going through each one and updating the correct person's information. This would work but would be slow, labour-intensive and could still generate errors e.g. if two people have the same name, or if someone replies with a false name.

To automate the process and (somewhat) protect against errors and malicious responses, you can give each person their own unique form with a unique identifier. When their response comes back you (or the computer) can look at the unique identifier and know that it came from the person it was supposed to.

The unique identifier in this case is the Airtable record ID. Every time you add a new row or record to a table on Airtable, Airtable automatically and instantly creates a string of letters and numbers to identify it. That string is guaranteed to be unique to that record and will not change even if you change all the other fields for that record. That way we could have to people called Mohamed Salah, for example, both aged 30, both 2m tall but with their own unique ID strings.

So we want to give each person their own form to fill in, with their unique ID attached to it in some way, so that we know for sure, who filled out the form when it comes back. A good way to do this, and the way you're using in your code, is with URL parameters. The URL is the address to the form on the internet. That's everything in your code from "" up until the first "?". After that it's all parameters.

Parameters are key value pairs, where you describe an attribute and then follow it with the data for that attribute. In the case of your question 1) we have "?" which just marks the start of a parameter (also called a query string) followed by "prefill_Guest%20ID" which is the key, an "=" which separates the key and the value and the finally you would get the value. If we want to add more parameters, we just add an "&" and start the pattern again.

So to explain the parameter in your question 1) the key describes the info you're about to receive in the value, in this case it's the Guest's unique ID that's mentioned above. So you could create a unique form for each person by going down the list of guests, one at a time, look-up the guest's unique Airtable ID, and add it to the end of the form URL in a parameter. For example the first Mo Salah has a unique ID of '123456abcdef', so his unique form URL would be

But that would take ages and would require you to repeat the process every time a new person is added. So instead you can have Airtable create the URL, with the unique parameters, automatically. Airtable already knows what the unique ID is for each person, you just need to tell it where to look and add it on to the end of the form URL, which will be the same for everyone.

So your code is a set of instructions to automatically create a URL, which contains instructions to tell Airtable, for sure, who is responding to the form. You're using one system, to create instructions for another system, to feed into another system.

To specifically address your question 2), these different systems interpret the same characters and symbols in different ways. The Airtable formula field treats an & as an instruction to join two strings together. But in this case you don't want that to happen, instead you want the & to appear in the URL because it's doing the job of separating two parameters. So it goes inside the " " and Airtable ignores it as an instruction.

In your question 3) the text "&hide_Guest%20ID=true" has a function in the URL parameter (I'm not familiar with what it does but I assume it hides a field on the form that would otherwise show the Guest ID), but is meaningless to your formula field. So when creating the formula, you place it in a string and it passes through to the output, uninterpreted, to be used in the URL. 

This is a good little article about URL parameters if you want to learn more about what you can do with them. Feel free to ask any more questions - I'm enjoying writing the responses. 

6 - Interface Innovator
6 - Interface Innovator

Wonderful! Thanks Jack!

I'll start reading the link you sent and experimenting more writing the code using new tables.

Will let you know if I have any further questions! Thanks again!

6 - Interface Innovator
6 - Interface Innovator

Hello again

I'm trying to add an additional field that needs to be prefilled in the form called 'Company'. Is this code correct?


Thank you!

It certainly looks correct, assuming you have a field called Company. Have you tried it and it didn't work or just checking first?

One thing to know that hasn't come up yet is how you refer to fields in your Airtable table when writing formulae. If the field name is just one word, like Company,  you can just write the word and it will detect it. But if there's a space in the field name, you need to wrap it in curly braces {} e.g. {Company Name}