Sep 05, 2019 08:57 AM
Hi,
Here is my code using record.get([“Attachments”]); :
function showListe() {
base("Works")
.select({ view: "Grid view" })
.eachPage(function page(records) {
records.forEach(function(record) {
var li = document.createElement("li");
li.textContent = record.get(["Attachments"]);
document.getElementById("root").appendChild(li);
});
});
}
which gets me :
If i do record.get([“Attachments”][“url”);
i get nothing…
Help!
Nov 14, 2019 08:48 AM
I worked through this on my own, here is my hobbyist solution… good is good enough, right?
// get the entire attachments data… everything
var urldata = [record.get(‘Attachments’)];
// stingify the data into one messey long piece of text.
var urldata2 = JSON.stringify(urldata);
// split the string into an array using an apostrophe (you need \" in the quotes)
var urldata3 = urldata2.split("\"");
// publish the URL so that I can make my link reference.
Format.href = urldata3[7];
EASY as PIE - Works in any Setup… good luck fellow coders :slightly_smiling_face:
Jan 15, 2020 04:31 AM
@Bill.French I am working in Google Scripts trying to send all of my data to a google sheet but the 100 records limit is killing me. I see you put here a method to extract the first hundred, do you have the iterative function to go on?
Jan 15, 2020 08:38 AM
Sure.
//
// get airtable records
//
function atGetTable_(baseID, tableName, apiKey)
{
// set the key if not passed in the argument
apiKey = (apiKey == undefined) ? airtableAPIKey : apiKey;
// create the urlfetch options object
const options = {
method: 'GET',
headers: {
'Authorization' : 'Bearer ' + apiKey,
'Content-type': 'application/json'
},
muteHttpExceptions : true
};
// setup the page loop
var offSet = true;
var currentPage = 0;
var aRecords = [];
var offsetParameter = "";
// iterate across the pages
while (offSet)
{
// log the page number to the console
Logger.log("Reading page " + currentPage);
// call the airtable api
var response = UrlFetchApp.fetch(airtableAPIEndpoint + baseID + "/" + encodeURIComponent(tableName) + "?pageSize=100" + offsetParameter, options).getContentText();
// concat the array for of records for the current page
aRecords = aRecords.concat(JSON.parse(response).records);
var offSet = JSON.parse(response).offset;
// is there more data?
if (offSet)
{
offsetParameter = "&offset=" + encodeURIComponent(offSet);
} else {
break;
}
// increment the page number
currentPage += 1;
}
var oRecords = {
"records" : aRecords
}
return(JSON.stringify(oRecords));
}
Jan 08, 2021 02:47 AM
This seems hacky but worked for me.
${JSON.parse(JSON.stringify(record.get([‘Image’][0])))[0][‘url’]}