Forum Discussion
Get Built-in variable (Slide.Id) when following storyline course
Hi,
As mentioned in the title, I like to know whether I can get the value of a built-in variable when executing JavaScript triggers. Specially Slide.Id variable when publishing a storyline in xApi format. I like to get the current slide when someone follows the articulate course. I want to get it as any output (variable, json, object) and use it outside of the package (in my project). How can I achieve something like this? I tried this way. But I couldn't get the value of the Slide.Id properly.
var player = GetPlayer();
player.SetVar("CurrentSlide", Slide.Id);
var getSlideId = player.GetVar("CurrentSlide");
alert("SlideID from variable: " + getSlideId );
This is my JavaScript code. I tried using "Slide.Id", "%Slide.Id%", %Slide.Id% as well. But nothing seems to work. Any help regarding this would be much appreciated.
- NedimCommunity Member
Try this code:
var player = GetPlayer(); var getSlideId = player.GetVar("CurrentSlide"); alert("SlideID from variable: " + getSlideId );
and trigger
Result:You can't reference the built-in variable directly in the JavaScript code.
- MauroBiscioneCommunity Member
Hello,
One way you can do it is store the value in a variable in Storyline:
Set CheckSlideID to variable Slide.Id
Then in your JavaScript trigger, pull the value from there:
var player = GetPlayer();
var CheckSlideID = player.GetVar("CheckSlideID");