I am encountering an issue with variable insertion in Google Apps Script. I have a script where I'm trying to insert a variable from AppSheet into a text template, but I'm getting "undefined" as the result.
Here's a simplified version of my code:
function createFolderAndGoogleDocInDrive(folderName, abNumber) {
// ... (folder creation and document copying)
// Logging the value for debugging
Logger.log(abNumber["AB nummer"]);
// Extract the value of "AB nummer" from AppSheet and insert it into the content
var abNumberValue = abNumber["AB nummer"];
var content = `
...
AB number : ${abNumberValue}
...
`;
newDoc.getBody().setText(content);
Logger.log("Folder and Google Document created with ID: " + newFolder.getId());
}
What am I doing wrong?
Solved! Go to Solution.
I have changed var abNumberValue = abNumber["AB nummer"];
to
varabNumberValue = abNumber;
Now it works
User | Count |
---|---|
17 | |
14 | |
8 | |
7 | |
4 |