Forum Discussion
AndrewRost
13 years agoCommunity Member
Retrieve LMS User Name as Variable
I know you can have a user fill in a text box with their name and then later use that variable for personalization. What we would like to do is programmatically retrieve the user name from the LMS....
SteveFlowers
8 years agoCommunity Member
Have been using the methods listed in the thread for years to get this to work with HTML5.
//this might not be required depending on how your LMS nests the API. Try with then comment out if it does not work in a test publish.
lmsAPI=parent;
//This splits the username sent by the LMS by the comma and creates a string Firstname Lastname.
var userName=lmsAPI.GetStudentName().split(',')[1]+" "+lmsAPI.GetStudentName().split(',')[0];
//get storyline's player
var player=GetPlayer();
//set a player variable in your storyline file to the string created above. Make sure the variable exists in Storyline.
player.SetVar("storylineNameVariable",userName);
Works every time for me in HTML5.