diff --git a/Code.ts b/Code.ts index 1cbdd18..eb2e497 100644 --- a/Code.ts +++ b/Code.ts @@ -1,3 +1,7 @@ +const DOCUMENT_TEMPLATE_IDS = { + Certification: '1V0uMuM80BGpjpdt1AmuzlU97tDI_u-y2rOfdl4tkqmc', +}; + const OUTPUT_FOLDER_ID = '1ROyJXk-QANTHM6Jiw0ne3EQiR1f2UsLr'; function onOpen() { @@ -80,7 +84,14 @@ function generateForRow( ) { const row = spreadsheetRowToObject(spreadsheet.getActiveSheet(), row_num); - const template_doc = DocumentApp.openById(row['Template ID']); + if (!(row['Document Type'] in DOCUMENT_TEMPLATE_IDS)) + throw new Error(`${row['Document Type']} is not a valid type of document!`); + + const template_doc = DocumentApp.openById( + DOCUMENT_TEMPLATE_IDS[ + row['Document Type'] as keyof typeof DOCUMENT_TEMPLATE_IDS + ] + ); const source_file = DriveApp.getFileById(row['Document ID']); const out_folder = DriveApp.getFolderById(OUTPUT_FOLDER_ID);