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
215 Replies
Hi Eduardo,
You'll need to click on the user's name to visit their profile. Then you'll see a "contact me" button to reach out to them specifically.
- EduardoRodri235Community Member
Thank you Ashley!
- JenniferHadjezCommunity Member
Newbie here - Is there a way for the variable to retrieve the user name without the user having to click a button?
- BrianAllenCommunity Member
Hello Jennifer,
Just add the trigger to execute the javascript to a shape positioned off the slide, and set that trigger to execute at the beginning of the timeline of your slide.
This will execute the trigger automatically and make the value available for you to use.
- JayDharapCommunity Member
Hey Jennifer!
You set up a variable called *newName* (you could call it anything you
want, just make sure the javascript I am about to share with you has the
same variable mentioned)And then you set up a trigger to run at the start of the timeline, to
execute javascript.And in the pace where the javascript is meant to go, you enter this:
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var arrayName = myName.split(' ');
var newName = arrayName[0];
player.SetVar("newName", newName);This works for my LMS. I'm no expert, but you can try this and ask around
if this doesn't work. There are versions of this floating around.
- PhilMayorSuper Hero
set the trigger to on timeline start of a slide
Hey Jennifer! Welcome to the E-Learning Heroes community - assistance like you're getting above is the best welcome I could think of!
- JenniferHadjezCommunity Member
Thank you, everyone! What a great response! I got it to work! Yay!
- JamesBonney-EDECommunity Member
Hi All,
In SL1, this code works for me on my Moodle LMS, but in SL2, it doesn't pull the name through. Can anyone tell me why it's no longer working?
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1];
player.SetVar("newName", newName);
Thanks
James
- SteveFlowersCommunity Member
Give this a shot:
var player = GetPlayer();
lmsAPI=parent;
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1];
player.SetVar("newName", newName);
- JamesBonney-EDECommunity Member
Steve, I salute you. Once again helping me out on here.
Really appreciate, thank you!
- RickForgeardCommunity Member
- BrianAllenCommunity Member
Rick, we also use SumTotal. I've got a couple of working examples of this script in Storyline 2 that we've tested in SumTotal. Let me know if you have trouble getting things working.
Hi Lucio!
Hopefully there are some users still subscribed to this thread that will be able to pop in and assist you here. If not, feel free to reach out to a user directly via the 'Contact Me' option on the user profile.
- LucioCommunity Member
Thank you both Leslie and Philip to get back to me.
In the meantime, I found this:
Though I haven't tested any of it yet, it may help someone in the future.
Related Content
- 3 years ago
- 9 months ago
- 9 months ago