I am trying to use google app maker to enter data. I want to export that data to a google docs template and create a PDF.
I have tried this link
Document Merge with Google App Maker But I get an error
Creating new record: (Error) : Invalid argument: replacement at
models.Clients.onAfterCreateEvent:13
at NewPage.Form1.Form1Header.Form1CreateButton.onClick:2:19
Wed Apr 03 10:27:12 GMT-500 2019
Creating new record failed.
Wed Apr 03 10:27:12 GMT-500 2019
(Error) : Invalid argument: replacement'
''' There is another form post link Google App Maker - Creating a contract. Methods to use? So I know its possible but I am new to making scripts and can't figure it out.
I have tried multiple different scripts Found here on Stackoverflow.
I want to be able to enter Data in App from APP maker. Than export to Google doc template. I am new to App Script and any help would be greatly appreciated Thank you
'''
var templateId = 'your template ID';
var filename = 'Document for Customer ' + record.ClientName + new Date();
var copyFile = DriveApp.getFileById(templateId).makeCopy(filename);
var copyDoc = DocumentApp.openById(copyFile.getId());
var copyBody = copyDoc.getBody();
var fields = app.metadata.models.Clients.fields;
for (var i in fields) {
var text = '<<' + fields[i].name + '>>';
var data = record[fields[i].name];
copyBody.replaceText(text, data);
}
'''
I am trying to get App maker data to import into a google doc template and than create a PDF of that doc with the imputed values in place of the placeholder.
I got it to link to the Google Docs but it comes back with a value of undefined. I am using SQL database
var templateId = '1IbbrRJhYSnfEmgUD1GYrjxEHeyseGtQFx-G3CzEC4mI';
var filename = 'Document for Customer ' + record.ClientName + new Date();
var copyFile = DriveApp.getFileById(templateId).makeCopy(filename);
var copyDoc = DocumentApp.openById(copyFile.getId());
var copyBody = copyDoc.getBody();
var fields = app.metadata.models.Clients.fields;
for (var i in fields) {
var text = '<<' + fields[i].name.valueOf() + '>>';
var data = record[fields[i].item];
copyBody.replaceText(text, data);
}
copyDoc.saveAndClose();