impossible to set a variable to (blank) using JavaScript from an external source?

Nov 01, 2018

I am having problems setting some variables outside of Storline 360 and reading them in so they can be identified.

Boolean variables and number variables work fine.

But it is text variables - principally when a text variable is set to be null or blank...

So logic that depends on a Storyline text variable being (blank) seems not to works if the text contains a string but not when reading in a blank or null...


The issue we had with the “is (blank)” logic is when doing:

window.GetPlayer().SetVar('C1Q1', null);



window.GetPlayer().SetVar('C1Q1', '');



The is (blank) logic doesn’t seem to treat empty strings or nulls as blank, so we think it’s impossible to set a variable to (blank) using JavaScript, despite us verifying the variable was set correctly.

Help please very much appreciated...


10 Replies
Chris Pim

Hi Matthew,

I need a flag set from outside - a variable that either contains text or is blank when the data are read in and out. Then the logic will either select or deselect a checkbox. Checking if the variable is not blank works, but if the variable is required to be empty, blank, null or effectively contain nothing then Storyline does not understand the contents/lack of content. It's as if 'blank' is not the same in Storyline as an empty text variable. We have verified that the variable is being read in correctly but not being interpreted correctly.


There are absolutely multiple ways to do this and the method you proposed does create a variable as a string. Specifically, it creates a string literal.

Normally, JavaScript strings are primitive values, created from literals:
let x = "John";

But strings can also be defined as objects with the keyword new:
let y = new String("John");

Interestingly enough, these 2 things are not equal.

If you tested to see if the values of x and y above were the same (x==y) it would return "true". 
However, if you tested to see if the value and the type were the same (x===y) it would return false. 

For this specific question, either will do, but in the spirit of moving you from Novice forward, just know that there is a difference and how you declare a variable can matter.