I'm looking to auto-populate the document's name into a single cell in sheets no matter if/when the doc name is changed. I can enter a formula from a script =DocName(), but it won't update when the document name is changed.

The script I used was

function DocName() { return SpreadsheetApp.getActive().getName(); }

I tried combining the =DocName() function with =IF(TODAY()=TODAY() but kept getting errors no matter how I formatted it.