Search code examples
javascriptgoogle-app-maker

Appmaker: How can I create and access global variables?


I am trying to make a button which acts as a switch, enabling the visibility of a panel. I am running a client side script when the onClick event fires, which is the following:

function {
  if(app.datasources.global.item.hideshow===false)
    {
       *does one thing*
    }
    else if(app.datasources.global.item.hideshow===true)
    { 
       *does another*
    }
}

My problem is, that the global (which is the datasource).item seems to be a null according to the console error log. It seems like i am trying to access one property of a record from a database, but I would like to access and edit a property which is not attached to any database, it would be just a "global variable".

Maybe I haven't phrased it too well, but I hope somebody can help me out with this. Thank you in advance.


Solution

  • There are a few ways you could do this. This link may help ontoggle Event. Another way I could see doing this would be using local storage.