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
- SteveFlowersCommunity Member
Hi, Julie -
This one works fine for me in HTML5. The problem with the beginning of the thread was the use of a function that only worked in Flash. The example below is available to both Flash and HTML5:
https://community.articulate.com/discussions/articulate-storyline/retrieve-lms-user-name-as-variable?page=6#reply-388873var player = GetPlayer();
lmsAPI=parent;
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1];
player.SetVar("newName", newName);
Could not have said that better myself Steve :) Thanks!
Hey Rick - perhaps you're just having difficulty with the older file. Re-attaching here for you to try as Wendy's suggestion should assist :)
- RickForgeardCommunity Member
Thanks Wendy and Leslie.
I was able to open the file. Will let you know how it goes.
Rick
- WendyFarmerSuper Hero
Hi Rick
what is in the ... code window and do you want the code to Execute when the timeline of the slide starts - you have it set on the variable 'name'.
Glad that was able to assist Rick :) Thanks for letting me know. Good luck with your project.
- RickForgeardCommunity Member
Thanks again Wendy and Leslie,
That did it. FYI, I triggered it on the timeline.
Rick
Great news Rick :)
- JamesBonney-EDECommunity Member
Hi Steve,
For some reason when publishing from 360 with HTML 5 and flash as a fallback, the code doesn't work anymore.
Anyone got any ideas?
- SteveFlowersCommunity Member
Hi, James - Which code are you using? This works for me in HTML5 publish.
var player=GetPlayer();
lmsAPI=parent;
var username=lmsAPI.GetStudentName();
player.SetVar("SLVariable",username);
//alert(username);- OgbishBarrowCommunity Member
Hello, please may I ask - is this the code for retrieving names from LMS? if so, where do I insert it. I am pretty new to Articulate
- ChrisPim-7dc640Community Member
Any resolution to this I can't get this working in 360 HTML5 output in any browser
-------------------
var player=GetPlayer();
lmsAPI=parent;
var username=lmsAPI.GetStudentName();
player.SetVar("SLVariable",username);
//alert(username);----------------------
Anyone got this working?
- JamesBonney-EDECommunity Member
Hi Steve,
Cheers for that, I'll give that one a go.
I was using the most recent code you posted previously (to me) on page 6 of this thread.
With 360 giving us the option for a preferred HTML5/Flash priority, how is this going to affect the choice of code we use? Could we encounter certain code not working depending on the format the course launches in?
Or would we need two triggers for the two different types of JS code? 1 for HTML5 and 1 for flash?