Save a document link in Google Sheets
This sets up an automation that watches one tab of a spreadsheet. When a row is added, a document is made from the row's columns and its link is written into a column of that row.
Prerequisites
- A Google account connected under Connectors.
- A template whose fields match your column headers.
- A column for the link, for example
Document.
1. Create the agent
On Agents, click New agent, then Start blank. Name it, open Settings and turn AI off: this agent runs the same fixed steps every time.
2. Choose the sheet
Open Run when and choose Google Sheets row under Also start it. Choose your Google account, paste the spreadsheet's link under Spreadsheet, and choose the Tab.
Leave Run when on A row is added, or choose A row is changed to run on edits. To run only when a box is ticked, set Only when this column changes to the column's header and To this value to TRUE.
3. Connect the spreadsheet
Google does not tell anyone about edits on its own, so a small script in the spreadsheet does. You add it once per spreadsheet. Under Connect the spreadsheet, click Show script and Copy script, then:
- In the spreadsheet, open Extensions → Apps Script.
- Delete any code there and paste the script.
- Click Save, choose
setupin the function menu, and click Run. - Come back and click Check again.
4. Make the document
Open Configure, click Add step, then Step, and choose Generate document. Pick the Template, and under Field values choose the row's columns for each field.
5. Write the link back
Click Add step, then Step, and choose Update spreadsheet row. Choose the same account, spreadsheet and tab, and the row from the trigger. Under Cells to write, put the document's link in your link column, for example Document.
6. Write errors into the row
Click the Generate document step and turn on If it fails. Click Add a fixed step, choose Update spreadsheet row, and write ERROR: and Why it failed into your link column. The row then shows the reason instead of a link, and the task completes.
7. Save a version
Click Save version, then add a row. Its link appears in the row within a minute.
Last updated on