This solution works with all types of Google application files (Docs, Sheets, Forms, ...)
You need to use driveapp
The code below refers to a form, for example:
const currentForm = FormApp.getActiveForm()
const formFile = DriveApp.getFileById(currentForm.getId())
const formName = formFile.getName()
Just get the document from the corresponding application, then use DriveApp to get the file by its identifier, after which you will have a file name
source
share