Yes, it is possible. However, there are a few things to consider:
Airtable's script editor does not support jQuery by default, so you would need to include the jQuery library in your script to use its AJAX functions. You can include jQuery by adding the following line at the top of your script:
var $ = require('https://code.jquery.com/jquery-3.6.0.min.js');
I hope it helps. Thank you
Yes, it is possible. However, there are a few things to consider:
Airtable's script editor does not support jQuery by default, so you would need to include the jQuery library in your script to use its AJAX functions. You can include jQuery by adding the following line at the top of your script:
var $ = require('https://code.jquery.com/jquery-3.6.0.min.js');
I hope it helps. Thank you
I tried this, but all I get when I test the script is:
ERROR
ReferenceError: require is not defined
at main on line 5
I tried this, but all I get when I test the script is:
ERROR
ReferenceError: require is not defined
at main on line 5
Hey @MrLuke - you can use the fetch method in Automation Run Script Actions to call external APIs.
You cannot require third-party dependencies using `require` in Scripting Extensions or Automation Run Script Actions. You can include npm packages and client-side Javascript with Custom Extensions, though they cannot be triggered by an Automation that you mentioned in your original question.
For your use case, I anticipate auth into Google's APIs may be difficult but probably possible.
And just since you mentioned Google Calendar specifically, are you aware of the native Google Calendar Sync feature? (no code required)
I tried this, but all I get when I test the script is:
ERROR
ReferenceError: require is not defined
at main on line 5
Sorry, Luke, it was my mistake; the Airtable script editor does not support the require() function, so you can't use it to include the jQuery library in your script.
Use the fetch() or XMLHttpRequest() JavaScript built-in functions to make your requests.
Here's an example of how you can use the fetch() function to make a GET request to the Google Calendar API to retrieve events for a specific calendar:
var calendarId = 'primary';
var apiKey = 'YOUR_API_KEY';
fetch(`https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events?key=${apiKey}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
// Do something with the data
console.log(data);
})
.catch(error => {
console.error(error);
});
Thank you.
Sorry, Luke, it was my mistake; the Airtable script editor does not support the require() function, so you can't use it to include the jQuery library in your script.
Use the fetch() or XMLHttpRequest() JavaScript built-in functions to make your requests.
Here's an example of how you can use the fetch() function to make a GET request to the Google Calendar API to retrieve events for a specific calendar:
var calendarId = 'primary';
var apiKey = 'YOUR_API_KEY';
fetch(`https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events?key=${apiKey}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
// Do something with the data
console.log(data);
})
.catch(error => {
console.error(error);
});
Thank you.
Thanks for this! The `fetch` method worked perfectly. I had already tried `XMLHttpRequest()` but that didn't work and was treated like it wasn't supported.
Hey @MrLuke - you can use the fetch method in Automation Run Script Actions to call external APIs.
You cannot require third-party dependencies using `require` in Scripting Extensions or Automation Run Script Actions. You can include npm packages and client-side Javascript with Custom Extensions, though they cannot be triggered by an Automation that you mentioned in your original question.
For your use case, I anticipate auth into Google's APIs may be difficult but probably possible.
And just since you mentioned Google Calendar specifically, are you aware of the native Google Calendar Sync feature? (no code required)
Thanks, I've got it working with `fetch` now. 🙂
I have tried to the Google Calendar sync, which is great, but we need some additional flexibility/editing which synced tables don't appear to allow or had some limitations on which a custom script should hopefully avoid.