Can you pass variables into storyline on startup?

Jul 11, 2017

Is it possible to pass variables into an instance of a Storyline course when it starts up - eg. to toggle a Boolean which shows/ hides a certificate page?

4 Replies
Luke Mosse

I've actually found this on another thread.

You can! The code is as follows:

function getQueryVal(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length;i++){
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
}
var player=GetPlayer();
//storyline variables userName and userID must exist for this to work
player.SetVar("userName", getQueryVal("userName"));
player.SetVar("userID",getQueryVal("userID"));

It uses "?" as a separator, and you append variables to the URL query. If
you need any help with it let me know. I had to repair the "for" loop
because on the original it had erased some of it on posting, so hopefully
this will remain in tact.

This discussion is closed. You can start a new discussion or contact Articulate Support.