I am trying to create a document from data that is stored inside of a Google Spreadsheet. I have created a function in a bound script (to the spreadsheet), that when triggered, should take the appropriate data and put it into a new document. However, I get a permissions error when I try it.
Can you create a google document (in your google drive) from a script bound to a spreadsheet? If so, how?
Here are some steps to duplicate the behavior:
From a basic google sheet:
| A | B | C | D |
1| First Name | Last Name | Ready | Function |
2| John | Doe | | |
3| Jane | Doe | | |
I created the following function using the script editor:
function createDocument(ready, row) {
if(ready) {
var data = Utilities.formatString("Hello %s %s", row[0][0], row[0][1]);
var doc = DocumentApp.create("Testing");
var body = doc.getBody();
body.appendParagraph(data);
return "Success"
}
}
D2 has the following call:
=createDocument(C2, A2:B2)
But when I enter "TRUE" into C2 (to trigger the creation of the document) I get the following error:
Error you do not have permission to call create (line 4).