Issue with Variable Insertion in Google Apps Script

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 Solved
0 3 1,448
1 ACCEPTED SOLUTION

I have changed  var abNumberValue = abNumber["AB nummer"];
to 
varabNumberValue = abNumber;
Now it works

View solution in original post

3 REPLIES 3