google-sheetsgoogle-apps-scriptgoogle-drive-api

recording logger result to a cell


I have a script that creates a new folder ID and displays the ID in the Execution log. I want to record that folder ID to cell A1.

I thought it would be as simple as

SpreadsheetApp.getActiveSpreadsheet().sourceSheet.getRange("A1").setValues(newFolderID);

where newFolderID = parentFolder.createFolder(newFoldername).getId();

What am I doing wrong?

The script to create the folder works fine, it's just recording the FolderID into a cell.


Solution

  • Solution used as per @PatrickdC's suggestion.

    I changed my initial attempt:

    SpreadsheetApp.getActiveSpreadsheet().sourceSheet.getRange("A1").setValues(newFolderID);
    

    to:

    sourceSheet.getRange("A1").setValue(newFolderID);
    

    This is the solution that worked for me.

    Creator's note: Originally posted by the OP as an "update" to the question in December 2024.