Forum Discussion
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. Is there a way to set a variable with data from the LMS when the course is loaded instead of having the user enter their name?
Thx
- PhilipLima1Community Member
Really hoping someone can help.
I am assuming the answer is something really silly. We have been retrieving the learner name from our LMS on many courses. all of a sudden, it will not work. Here is the slide that retrieves the name. Does anyone have any idea why this won't work?
- SteveFlowersCommunity Member
Hi Philip -
If the LMS changed something, it could require a slight shift. Add the bolded line below to see if something changes.
var player = GetPlayer();
lmsAPI=parent;
var myName = lmsAPI.GetStudentName();var array = myName.split(',');
var newName = array[1] + ' ' + array[0];player.SetVar("newName", newName);
- PhilipLima1Community Member
Hi Steve. Thanks for the suggestion, but that didn't fix it.
- PhilipLima1Community Member
Hi Steve. Thanks for the suggestion, but that didn’t fix it.
- SteveFlowersCommunity Member
What LMS is this running in? Does anything alert adding this line to the top?
lmsAPI=parent;
var myName = lmsAPI.GetStudentName();
alert(myName);Another potential cause is a script erroring out and preventing the call from executing. In Chrome (or another modern browser), try opening the browser console. Hamburger menu > More Tools > Developer Tools. Click the console tab then drop down the menu at the top labeled <top frame>, selecting the storyline window and look for errors to appear in the console.
- PhilipLima1Community Member
when running adding:
alert(myName);
a pop-up does appear with my name.
- PhilipLima1Community Member
but, my name still does not appear on the screen in the course itself.
- PhilipLima1Community Member
OMG! cannot believe we forgot to add it to the variable manager! Testing now.
- PhilipLima1Community Member
That did it Steve. I can't believe it. I am 13 hours in on a marathon day. Example of the law of diminishing returns - possibly.
I really appreciate the help.
- PhilipLima1Community Member
Thank you Steve!
Hi Stephanie! Brian's response was over a year ago, so I'm not sure if he would still be subscribed to the thread. You are welcome to reach out to him directly via the 'Contact Me' option on his user profile.