I don’t think project variables are accessible with JavaScript. Try creating your own variable and then assign the project variable to your created variable using a trigger. You should then be able to access your own variable using JavaScript.
Try using quotation marks to see if this fixes the problem:
var viewed = player.GetVar("Project.SlidesViewed");
Using quotation marks says to grab what it is called inside of Storyline and without quotation marks assumes it is a variable you want to pass in that you have defined in your JavaScript.
FYI - I'm using SL 3 so I'm not sure how the builtin variables are being shown now in 360 but if you can't get the variable as written try dropping the Project. to see if that works.
Try using quotation marks to see if this fixes the problem:
var viewed = player.GetVar("Project.SlidesViewed");
Using quotation marks says to grab what it is called inside of Storyline and without quotation marks assumes it is a variable you want to pass in that you have defined in your JavaScript.
FYI - I'm using SL 3 so I'm not sure how the builtin variables are being shown now in 360 but if you can't get the variable as written try dropping the Project. to see if that works.
Hope that helps!
Hello Thor Melicher,
i am aware that quotation marks will convert the content available within to string, the problem i am referencing here is that i am not able to call getPlayer() function.
Error Detail:
user.js:2 Uncaught ReferenceError: getPlayer is not defined
i traversed around this community and found alot of solutions posted like:
1. use parent.getPlayer() instead of getPlayer(), in my case not working.
2. use timeout for few seconds, in my case not working
I don’t think project variables are accessible with JavaScript. Try creating your own variable and then assign the project variable to your created variable using a trigger. You should then be able to access your own variable using JavaScript.
Allthough i dont have Storyline3, only 360 i do think there is no delay needed. I think in the original poster code was just an error calling getPlayer instead of GetPlayer.
All Storyline internal functions have to be strictly coded as is. This code works fine in 360 and i suppose in 3 too.
let player = GetPlayer();
let testVar = player.GetVar("test");
console.log("value: "+testVar);
Offcourse you need a custom variable called test. If you need a project variable available in your Javascript, you use a trigger to set a custom variable to the project variables value.
10 Replies
I don’t think project variables are accessible with JavaScript. Try creating your own variable and then assign the project variable to your created variable using a trigger. You should then be able to access your own variable using JavaScript.
Try using quotation marks to see if this fixes the problem:
var viewed = player.GetVar("Project.SlidesViewed");
Using quotation marks says to grab what it is called inside of Storyline and without quotation marks assumes it is a variable you want to pass in that you have defined in your JavaScript.
FYI - I'm using SL 3 so I'm not sure how the builtin variables are being shown now in 360 but if you can't get the variable as written try dropping the Project. to see if that works.
Hope that helps!
Hello Thor Melicher,
i am aware that quotation marks will convert the content available within to string, the problem i am referencing here is that i am not able to call getPlayer() function.
Error Detail:
user.js:2 Uncaught ReferenceError: getPlayer is not defined
i traversed around this community and found alot of solutions posted like:
1. use parent.getPlayer() instead of getPlayer(), in my case not working.
2. use timeout for few seconds, in my case not working
i will give it a try.
Solution to my GetPlayer Problem:
SetTimeout is must to provide delay.
And for variable problem only user defined variable can be accessed
Very interesting that you had to create a delay to get it to work. Which LMS are you using?
i am not using any lms. i am directly publishing the content to html. using php, i am calling the story.html in iframe which hides its name.
have the same issues
help setTimeout, but to wait 1 second for it is confusing
Have anybody solved this issue?
any updates on this?
Allthough i dont have Storyline3, only 360 i do think there is no delay needed.
I think in the original poster code was just an error calling
getPlayer
instead ofGetPlayer
.All Storyline internal functions have to be strictly coded as is.

This code works fine in 360 and i suppose in 3 too.
let player = GetPlayer();
let testVar = player.GetVar("test");
console.log("value: "+testVar);
Offcourse you need a custom variable called test.If you need a project variable available in your Javascript, you use a trigger to set a custom variable to the project variables value.
Like shown here.