Storyline - Retrieve and Display Learner Name

You can call a JavaScript on any trigger in Storyline to retrieve the learner name, split into first and last names, and set variables using the following code.


var player = GetPlayer();

var myName = lmsAPI.GetStudentName();

var array = myName.split(',');

// variables for JavaScript
var firstName = array[1];
var lastName = array[0];
var fullName = firstName + ' ' + lastName;

// variables in Storyline set to variables from JS above
player.SetVar("fullName", fullName);
player.SetVar("firstName", firstName);
player.SetVar("lastName", lastName);


Sample file attached.

P.S. - Things weren't working correctly when I tried to combine in one trigger this JavaScript with another that's function was to retrieve the date. Once I broke them out into separate slide triggers all worked fine. Just thought I'd capture and share that somewhere.

Be the first to reply