title: How to store global values correctly using Properties service in GAS?
body: <p>I have this problem using Google apps script.
  I have a menu in a spreadsheet with two options (Set Password and Add Time Record).  These options raise a UI service user interfaces for prompt its data respectively. For access to Add Time Record I ask before if user is authenticated.  I use scriptProperties = PropertiesService.getScriptProperties() and setProperty('authenticated', false)  for save the initial value of authenticated.</p>
  
  <p>1-  I click Set Password,  I do login ok and close the UI.</p>
  
  <p>2-  I click Add Time Record  and I expect to receive my AddTime record Ui (because I Set Password first) but instead I receive Set Password UI. Even if I login again I receive the same UI …again and again. </p>
  
  <p>Is like authenticated is reset to false every time I do click in a menu option no matter the action I did before. This is the expected behavior? Or I’m doing anything wrong? Thanks a lot for your help.</p>
  
  <pre><code>var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('authenticated', 'false');
  function onOpen() {
    var ui = SpreadsheetApp.getUi();
    ui.createMenu('ProWorkflow')
      .addItem('Set Pasword', 'getPassword').addSeparator()
      .addItem('Add Time Record', 'isAuthenticated').addSeparator()
      .addToUi();
  }
  function isAuthenticated()
  {
    var scriptProperties = PropertiesService.getScriptProperties();
    var value = scriptProperties.getProperty('authenticated');
    if(value =='false'){
      getPassword(); // at the end of this function I set scriptProperties.setProperty('authenticated', ‘true’);
    }
    return addTimeRecord();
  }
  function getPassword(e)
  {
      …
      …
      …
     var scriptProperties = PropertiesService.getScriptProperties();
     var value = scriptProperties.getProperty('authenticated');
     value = 'true';  
     scriptProperties.setProperty('authenticated', value); //change de value of uthenticated 
     return app.close(); 
  }
  </code></pre>