This topic was automatically generated from Slack. You can find the original thread here.
There used to be a trigger to track changes in a Google Sheets file stored in a shared drive. It seems this trigger doesn’t exist anymore. Instead, there’s a trigger “Changes to Specific Files (Shared Drive) from Google Drive”. Unfortunately, this one doesn’t show the changes made to the file. What’s the best way to trigger a upon changes in a Google Sheets file?
To track changes in a Google Sheets file, you can use the “Changes to Specific Files (Shared Drive)” trigger from Google Drive. However, if this trigger does not provide the detailed changes you need, you can consider the following approach: 1. Google Sheets API: Use the Google Sheets API to programmatically detect changes. You can set up a Pipedream workflow with an HTTP trigger that listens for changes. This requires setting up a Google Apps Script or another service to send a webhook to your Pipedream workflow when changes occur. 2. Google Apps Script: Write a Google Apps Script that monitors changes in the Google Sheets file. You can use the onEdit trigger in Google Apps Script to detect when a cell is edited. Then, use the script to send a webhook to your Pipedream workflow. Here’s a basic outline of how you might set this up: ### Google Apps Script Example function onEdit(e) { const sheet = e.source.getActiveSheet(); const range = e.range; const value = range.getValue(); const payload = { sheetName: sheet.getName(), range: range.getA1Notation(), value: value, }; const options = { method: 'post', contentType: 'application/json', payload: JSON.stringify(payload), }; UrlFetchApp.fetch('YOUR_PIPEDREAM_WEBHOOK_URL', options); } ### Steps to Implement 1. Create a Google Apps Script: - Open your Google Sheets file. - Click on Extensions > Apps Script. - Copy and paste the above script into the editor. - Replace 'YOUR_PIPEDREAM_WEBHOOK_URL' with your actual Pipedream webhook URL. - Save the script and set up the onEdit trigger. 2. Set Up a Pipedream Workflow: - Create a new workflow in Pipedream. - Use an HTTP trigger to receive the webhook from your Google Apps Script. - Add actions to process the data as needed. This setup will allow you to trigger a Pipedream workflow whenever a change is made to the Google Sheets file, and you can customize the script to send specific data about the changes. If you need further assistance, you can visit Pipedream Support for more help.
Hi . Thank you, this a possible workaround. Do you know how to adjust the apps script to wait a certain amount of time and send all changes within that timeframe?
To adjust an app script to wait for a certain amount of time and send all changes within that timeframe, you can use Pipedream’s built-in delay functionality. Here are the steps you can follow: 1. Use the Delay Action: Pipedream provides built-in Delay actions that you can use to pause the execution of your workflow for a specified amount of time. This is useful if you want to batch changes and send them after a delay. 2. Use Node.js Code with $.flow.delay: If you prefer to use code, you can implement a delay using the $.flow.delay function in a Node.js code step. This function allows you to specify the amount of time to wait before proceeding to the next step. Here’s an example of how you might use the $.flow.delay function in a Node.js code step: ```
export default defineComponent({ async run({ steps, $ }) { // Delay for 1 hour (3600 seconds) await $.flow.delay(3600); // After the delay, proceed with sending changes // Add your logic here to send the changes }, });