This topic was automatically generated from Slack. You can find the original thread here.
Hey guys, I’m trying to use a Google Sheets event to add data in a specific column on a trigger of a new row created. I.e. I create a new row in Google Sheets by filling in A2, and I want PipeDream to add content to cell B2. I can’t for the life of me figure out how to do this. can anyone help please? Much apprecaited
Of course! I understand you want to add data to a specific column in Google Sheets when a new row is created. To achieve this, you can use Pipedream’s Google Sheets integration. First, you’ll need to set up a trigger for when a new row is created in Google Sheets. You can use the “New Row” event source in Pipedream. Search for “Google Sheets” and then “New Row” in the Pipedream UI. Next, you’ll need to add an action step to update the cell in column B of the new row. You can use the “Update Cell” action from the Google Sheets integration. Search for “Google Sheets” and then “Update Cell” in the Pipedream UI. In the “Update Cell” action, you’ll need to provide the following information: 1. Spreadsheet ID: The ID of the Google Sheets document where the new row is created. 2. Sheet Name or ID: The name or ID of the sheet within the document. 3. Cell: The cell you want to update (e.g., B2). 4. Value: The value you want to add to the cell. Make sure to use the data from the “New Row” trigger to set the appropriate cell and value in the “Update Cell” action. If you need more help or have any questions, feel free to ask!
how do I make the cell update dynamic? I.e. the action let’s me specify a cell, but I don’t want B2 to be updated every time. Another action should update C2. Furthermore, when a new row is added, I want to update B3 and C3
To make the cell update dynamic, you can use the data from the “New Row” trigger to determine the row number and update the appropriate cells accordingly. Here’s an example of how you can achieve this: 1. Set up the “New Row” trigger as mentioned in my previous response. 2. Add a “Run Node.js code” action step to determine the row number and the cells to update. 3. Add the “Update Cell” action step for Google Sheets and use the output from the previous code step to update the cells dynamically. Here’s an example of the code step to determine the row number and the cells to update: export default defineComponent({ async run({ steps }) { const newRowData = steps.trigger.event; const rowNumber = newRowData.rowNumber; const cellB = `B${rowNumber}`; const cellC = `C${rowNumber}`; return { cellB, cellC }; }, }); Now, in the “Update Cell” action step for Google Sheets, use the output from the previous code step to set the appropriate cell and value. For example, to update cell B, set the “Cell” field to {{steps.code_step_name.outputs.cellB}} and for cell C, set it to {{steps.code_step_name.outputs.cellC}}. Replace code_step_name with the actual name of your code step. This way, whenever a new row is added, the cells in columns B and C of the new row will be updated dynamically.