Storyline Boolean Variables are passed as String instead of Boolean

In a previous post last year, I showed how to use JavaScript to save a ton of time dealing with variables.

It turns out that something happened inbetween then and now. That "something" is that Storyline is passing Boolean variables to JavaScript as String, instead of Boolean. That means even if a Storyline variable is "true," in Storyline, it's not going to be true in JavaScript. (Because you're comparing a String to a Boolean)

I had to modify the script to make this work:

var bool = false;

var play = GetPlayer();

bool = (String(play.GetVar("StorylineBooleanVariable"))=="true");

This way, the "StorylineBoolanVariable" (which is Boolean is Storyline) is first parsed as String. Then, it is compared to the string "true". 

Hope it helps. There's a download in the link above to see. My two cents: use numbers: 0 and 1 if you can, instead of Booleans. (You can toggle Booleans in Storyline as well using the "Not" in adjust variable trigger. However, you can't do that with multiple variables, only one by one.)  

1 Reply