Feb 25, 2021 04:53 PM
Hello,
My input are:
idStock
getURL
getApiKeylabel
getApiKey
My code:
let table = base.getTable("Stocks");
let query = await table.selectRecordsAsync();
console.log(query.records);
let inputConfig = input.config();
console.log(`The value of idStock is ${inputConfig.idStock}`);
console.log(`The value of getApiKey is ${inputConfig.getApiKey}`);
console.log(`The value of getURL is ${inputConfig.getURL}`);
let mergeAPI = (`${inputConfig.getApiKeylabel}=${inputConfig.getApiKey}`);
let mergeURL = (`${inputConfig.getURL}${inputConfig.idStock}?${mergeAPI}`);
console.log(`The value of mergetURL is ${mergeURL}`);
let response = await fetch(`${mergeURL}`);
console.log(await response.json("price:"));
I want to output my json result to a field.Is it possible?
Feb 25, 2021 05:24 PM
Welcome to the Airtable community!
Yes, an automation can update field value for a record. You use the updateRecordAsync
method on the table object. If you want to create a new record, use createRecordAsync
. If you are updating the triggering record, you’ll need an input variable for the triggering record’s record ID.
These are all explained in the scripting documentation.
I recommend a long text field for storing the JSON.
Feb 25, 2021 07:09 PM
Thank you @kuovonne for your answer. I have a hard time to figure it out lol.
Feb 26, 2021 09:55 AM
Hello,
I really tried to understand the documentation. Is there anyone know how to pass json() to a Output in automation?
output.set( jason()) ??
Feb 26, 2021 10:03 AM
The documentation for how to use output.set
is here.
Feb 26, 2021 11:42 AM
Thanks, but I already know that page. however, it’s lack of details and information. The reason why I am looking now in the forum for help.
Feb 26, 2021 12:27 PM
As the documentation states, output.set()
takes a key/value pair. Your example is trying to pass a value without a key.
Seems like all you’d need to do is, instead of just console logging it, setting await response.json('price:')
as a variable such as responseJSON
and then on the next line write output.set('myJSONoutput', responseJSON)
.
^ From there you can use an Update Record action step using the output myJSONoutput
in a LongTextField as kuovonne suggested.
Feb 26, 2021 02:15 PM
Can you clarify why you want to use output.set()
? output.set()
is used in an automation to pass a value to a different action further down in the automation. It is not used directly to set field values.