Forum Discussion
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
- Jürgen_Schoene_Community Member
is the spelling of the variable identical ?
if the variable name in javascript is wrong you get always "null"
https://360.articulate.com/review/content/7783a56a-5306-4499-a8cf-30e97e7123d3/review
- MuhammadMuza137Community Member
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.
- MuhammadMuza137Community Member
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_Community Member
have you tried my attachment ?
if you cannot solve the problem in your file, please upload your .story file
- WaltHamiltonSuper Hero
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.