LUCA DELLA GHEZZA
LUCA DELLA GHEZZA

Reputation: 53

How to get nerw file ID after DriveApp moveTo

var idRisultati = DriveApp.getFileById(ssNew.getId()).moveTo(DriveApp.getFolderById(idCartellaEsame));
  
var ssNeww = SpreadsheetApp.openById(idRisultati.getId());

The "move to" operation works fine and the file appears in the desired folder, but IdRisultati contains only the name of the new file created. How can I obtain the new file Id?

Upvotes: 0

Views: 46

Answers (1)

Cooper
Cooper

Reputation: 64100

Try it this way:

const file = DriveApp.getFileById(ssNew.getId()).moveTo(DriveApp.getFolderById(idCartellaEsame));
  
var ssNeww = SpreadsheetApp.openById(file.getId());

Upvotes: 1

Related Questions