0

So I am trying to use apps scripts to make a function so that I can provide a file url and get the file name in app scripts. Here is the function that I have that keeps giving me a permission error.

function getSSName(url) {
  var ss = SpreadsheetApp.openByUrl(name);
  return(ss.getActiveSheet().getName());
 }
1
  • Are you trying to create a custom functions in Google Sheets? or you plan to call this function from another function in your script? By the way var ss = SpreadsheetApp.openByUrl(name); name is not defined, it should be url Commented Jun 21, 2021 at 20:48

1 Answer 1

1

This should do the trick:

function getSSName(url) {
  return DriveApp.getFileById(url.split('/')[5]).getName();
}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.