I'm running an Apps Script in Google Sheets to Mail merge and generate a PDF file which is then store in Drive.
I have the following variable which stores the Google Doc that serves as template for the new PDF being generated.
var GDOC_TEMPLATE_ID = '1olnBowCh-1apK3jWN-Lr2Ty3UT1NK_dmoJOVBjnzgO8'
I would like to have a function that modifies the value of this variable so that it can point to a different file.
What I have been trying to do is the following script but haven't accomplished at all:
- If "selected row's column N cell is empty, use this file, if cell is not empty, change to a different file ID.
Note: My mail merge script runs by selecting row and gets all the place holders from the selected row, so when one of those fields is empty, I'm trying to point to a different template that suits better.
Thanks
I believe your goal is as follows.
1olnBowCh-1apK3jWN-Lr2Ty3UT1NK_dmoJOVBjnzgO8asGDOC_TEMPLATE_ID. When the value of column "N" is not empty, you want to use the other file ID asGDOC_TEMPLATE_ID.In this case, how about the following modification? Please modify
getSheetData()as follows.From:
To:
Please replace
### other ID ###with your file ID.1olnBowCh-1apK3jWN-Lr2Ty3UT1NK_dmoJOVBjnzgO8is used asGDOC_TEMPLATE_ID. When the value of column "N" is not empty, the other file ID### other ID ###is used asGDOC_TEMPLATE_ID.