Fix "ScriptProperties is not defined" (and UiApp, DocsList, ScriptDb…)
ReferenceError: ScriptProperties is not defined
TypeError: Utilities.jsonParse is not a function
ReferenceError: UiApp is not defined
Projects old enough to run on Rhino usually also call services Google has since shut down. Migrating to V8 is the moment to fix them.
Direct replacements
| Removed | Use instead |
|---|---|
ScriptProperties.getProperty(k) | PropertiesService.getScriptProperties().getProperty(k) |
UserProperties.setProperty(k, v) | PropertiesService.getUserProperties().setProperty(k, v) |
DocumentProperties.… | PropertiesService.getDocumentProperties().… |
Utilities.jsonParse(s) / jsonStringify(o) | JSON.parse(s) / JSON.stringify(o) |
Session.getTimeZone() | Session.getScriptTimeZone() |
Session.getUser() | Session.getActiveUser() / Session.getEffectiveUser() |
// Old
ScriptProperties.setProperty('lastRun', new Date().toISOString());
var cfg = Utilities.jsonParse(UserProperties.getProperty('cfg'));
// Current
PropertiesService.getScriptProperties().setProperty('lastRun', new Date().toISOString());
var cfg = JSON.parse(PropertiesService.getUserProperties().getProperty('cfg'));
Services that need a rewrite
- UiApp →
HtmlService(sidebars/dialogs) orCardService(add-ons). - DocsList →
DriveApp(getFilesByName,getFolderById,searchFiles). - ScriptDb → a Sheet,
PropertiesServicefor small data, or JDBC / Firestore. - Xml (old service) →
XmlService. SoapService →UrlFetchApp+XmlService. - ContactsApp (deprecated) → People advanced service.
How V8Shift handles it
Properties, Utilities.json* and the deprecated Session methods are rewritten automatically. UiApp, DocsList, ScriptDb, Xml, SoapService and Finance are flagged for manual work.