Lawyers, operations teams, many of us perform repetitive, time-consuming, error-prone tasks, including filling out templates for NDAs, offer letters, employment agreements, consulting agreements, and more.
Save yourself time and reduce errors by automating those tasks.
Here’s a relatively simple way to take data from a form or spreadsheet and use that data to perform one or more manual tasks.
The script we’re going to use will take the first row of data in a Google Sheet and search for those terms in a Google Doc. If it finds a term, it will replace the term with the the text from the last row with data in it.
Anyone can do this! No need to be an engineer.
- Create your template
First, create your Google Doc template with the placeholders that you’ll want to replace with the custom data.
For example, something like this:
You’ll probably want to mark the terms that you’re going to replace with some kind of beginning and ending marker like # #, as I used above. But be careful what you choose, the script we’ll use may interpret some characters like [ ] as special characters and those may break the script. Having markers will make the process simpler, but it’s not necessary.
2. Create your data source
Second, create your Google Sheet data source.
You can enter the data directly into a Google Sheet or you can use a Google Form.
If you do use a Google Form, you’ll want each question to be identical to the text that you want to replace. For example, here’s the form that would go with the sample template:
That form produces a Google Sheet like this:
Because the Google Form just makes a Google Sheet, if you prefer, you can just type directly into a Google Sheet. If you do, the first row has to be the search terms and the rows below are the replacement terms.
The script that we’re going to create will search the Google Doc for #DATE TODAY# from column B in the Google Sheet. If that term is in the Google Doc, then the script will replace that term with the last date in that column (in this case September 9, 2017).
3. Create your script
Finally, create your Google Apps Script. For this part, you create a new script just like you’re creating any other new Google Suite element in Google Drive:
Then copy and paste in the script from github.
Insert the three IDs at the top of the script that correspond to your template file, source file, and output folder.
Save the file (unlike other Google products, you have to click save).
4. Run it
That’s it. You’re ready to run your script.
Enter some data into the Google Form or Google Sheet.
Then change the script dropdown to “main”:
Last, run the script with the play button:
You may have to give some permissions for the script to run, but after you do that, it should work!
This is version 1, so I’ll be adding more features over time.
Hope that’s useful!
Thanks for reading.