0

I use this simple script:

  var scriptProp = PropertiesService.getScriptProperties();
  var test = scriptProp.getProperty("test");

But the execution is terminated at the second line because the property do not exist. I thought getProperty would return null if the property did not exist.

Is it the case ? And if not, how to test the existence of a property ?

Note : I've tested a creation of the same property and it works well : after that, I can get my property.

coutier eric
  • 949
  • 5
  • 18
  • I think that when `test` is not existing, `null` is returned from `scriptProp.getProperty("test")`. And also, when I tested your script, I could confirm that `null` is returned with and without V8. So as a example script for checking whether the key of `test` is included in the script properties, how about this? `const res = PropertiesService.getScriptProperties().getKeys().filter(e => e == "test")[0];` In this case, when the key of `test` is existing and not existing, `test` and `null` are returned, respectively. If this was not the direction you expect, I apologize for this. – Tanaike May 03 '20 at 12:12
  • The debugger doesn't work properly. – TheMaster May 03 '20 at 12:16
  • It's very good if null is returned. But after these lines I have others that must manipulate the "test" variable but when I debug the script, it's terminated on the getProperty line of code and do not continue – coutier eric May 03 '20 at 12:18

1 Answers1

4

This is a known issue. Consider creating a new issue in the issuetracker or starring this related issue, if you think they're sufficiently related.

Related questions:

TheMaster
  • 45,448
  • 6
  • 62
  • 85