Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Apr 22, 2021 12:28 AM
I am using Airtable to send data through to another platform (Formstack Docs aka Webmerge). My base has a main record with a number of linked records per main record.
The use case is that each item from the linked records will be a new row on a document. In order to do that, I need to send the data through to the document in JSON.
Is there a way that I can produce the JSON of the linked records with a script within Airtable? Ideally I could put that JSON into a long text field.
Failing that, is using a code step in Zapier the only other option?
Thanks
Shaun
Solved! Go to Solution.
Apr 22, 2021 06:12 AM
No scripting needed. Create the JSON with a formula field in the linked table and a rollup field in the current table.
Apr 22, 2021 06:12 AM
No scripting needed. Create the JSON with a formula field in the linked table and a rollup field in the current table.
May 02, 2021 06:13 PM
@kuovonne I did the formula like this to create the JSON. It works, but I’m wondering if I went a long way about it…let me know if you would have done it differently?
CONCATENATE("{","\"","Full_Name","\""," ",":"," ","\"",Mem_Full_Name,"\"",",","\"","Address_1","\""," ",":"," ","\"",Mem_Add1,"\""," ,"," ","\"","Address_2","\""," ",":"," ","\"",Mem_Add2,"\"",","," ","\"","City","\""," ",":"," ","\"",Mem_City,"\"",","," ","\"","State","\""," ",":"," ","\"",Mem_State,"\"",","," ","\"","Zip","\""," ",":"," ","\"",Mem_Zip,"\"","}")
May 02, 2021 08:12 PM
There are many ways to do things in code.
If your formula works, and you understand it, congratulations!
I find formulas easier to maintain when written across multiple lines. You also do not need to escape your double quotes if you put your strings inside single quotes. I also like including newline characters and other white space to make the result more human-readable.
Here is a sample of my coding style for the first two key/value pairs.
CONCATENATE(
'{\n',
' "Full_Name": "' & {Mem_Full_Name} & '",\n',
' "Address_1": "' & {Mem_Add1} & '"\n',
'}'
)
Note that this assumes that there are no quotes or other characters in the fields that need to be escaped.