Forum Discussion

MuhammadMuza137's avatar
MuhammadMuza137
Community Member
2 years ago

is Javascript no longer to access (set or get) player's variable?

I'm using storyline v3.8 pretty latest. I saw a lot of forums and videos where people easily access user's variables (that we set in triggers) while for me it doesn't work at all and it always gives back "null". Is it something that storyline intentionally discontinued or am I missing something.

I've two examples:

I set a variable "userEmail" in a trigger and it is accessible on other slides through triggers. But I'm trying to use this variable in Execute Javascript and there I always get "null". Here's what I'm doing:

var player = GetPlayer();

var userEmail = player.GetVar("userEmail");

alert(userEmail); // always null

Also in another example I try to set a variable in player and right away access it in next line and it is still "null"

var player = GetPlayer();

player.SetVar("userEmail", "test@gmail.com");
var userEmail = player.GetVar("userEmail");

alert(userEmail); // always null

  • yes it is exactly same, I'm curious how it worked for you. Are you using the paid version? Because this can only be a difference if you also copied the same code as mine. 

  • and also what version of storyline you used? I used 3.80 and in the meantime also upgrade it to 3.81 but still it didn't run. I can purchase the full version as well if it is only happening because of trial version

    • Jürgen_Schoene_'s avatar
      Jürgen_Schoene_
      Community Member

      have you tried my attachment ?

      if you cannot solve the problem in your file, please upload your .story file

  • It is not happening because you have the trial version. The trial version IS the paid version, except after the trial time, it will stop running. 

    If the alert dialog shows, and the variable is null, you need to check SL and make sure it is working. If the dialog doesn’t show, the problem is the JS.