Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Mar 16, 2023 05:11 AM
function blabla()
{
// Replace the placeholders below with your own API keys and table information
var airtableApiKey = '-';
var airtableBaseId = '-';
var airtableTableName = '';
// Get the active sheet and the range of cells containing your data
var sheet = SpreadsheetApp.getActiveSheet();
console.log(sheet.getName());
var dataRange = sheet.getRange(3,1,sheet.getLastRow(),5);
// Get the values in the range as a 2D array
var data = dataRange.getValues();
var headers = {
'Authorization': 'Bearer ' + airtableApiKey ,
'Content-Type': 'application/json'
};
// Loop through the data in Google Sheets and send it to Airtable
for (var i = 0; i < data.length; i++)
{
var rowData = data[i];
var fields =
{
'Rack': rowData[0], <-- THIS FIELD TYPE is "link to another record"
'Line #': rowData[1],
'SKU': rowData[2], <-- THIS FIELD TYPE is "link to another record"
'Stocklist Notes': rowData[3],
'Stocklist Desc': rowData[4]
}
var options =
{
'method': 'post',
'headers': headers,
'payload': JSON.stringify({fields: fields})
};
// Send the data to Airtable
UrlFetchApp.fetch(apiUrl, options);
}
}
// it works fine for the field that is not field type "link to another record" anyone know how to solve this problem ?
// it works fine for the field that is not field type "link to another record" anyone know how to solve this problem ?
0 Replies 0
