devonhg

Airtable: Create Comment Via Scripting

Aug 5th, 2024 (edited)
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*******
  2. Instructions
  3. 1. Configure the variables below under "Configuration"
  4. 2. Set up your inputs. You can modify the configComment however you please but make configRecord just drop in a string for the record ID.
  5. 3. Test it to see if it works. If it isn't the console outputs the error for you.
  6. *******/
  7.  
  8. let inputConfig = input.config();
  9. //Configuration
  10.     let configBase = "app---";// You can retrieve these values from the URL of any open table
  11.     let configTable = "tbl---";
  12.     let configRecord = inputConfig.recordID;//Pass a value into here from input variables
  13.     let configComment = "Hello there! This is a comment!";//Modify however you want.
  14.     let configBearerToken = "---";//To generate this, look here: https://airtable.com/create/tokens
  15.  
  16. //Variables
  17.     let bodyContent = JSON.stringify({
  18.         'text': configComment
  19.     });
  20.     let url = 'https://api.airtable.com/v0/' + configBase + '/' + configTable + '/' + configRecord + '/comments';
  21.  
  22. //Create the Comment
  23.     let response = await fetch(url, {
  24.         method: 'POST',
  25.         headers: {
  26.             'Authorization': 'Bearer ' + configBearerToken,
  27.             'Content-Type': 'application/json',
  28.         },
  29.         body: bodyContent
  30.     });
  31.     console.log(await response.text());
  32.  
Advertisement
Add Comment
Please, Sign In to add comment