Storyline 360: Unable to fetch user name from LMS using javascript
Jun 16, 2020
By
Shipra Jain
I could really use any help or direction. I am using a simple javascript that was shown in various community discussions and appears to work for others. I want to create a custom certificate which user can print when he passes the course and for that, I want to fetch user name from LMS using javascript.
It isn't working for me!
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName1 = array[1] + ' ' + array[0];
player.SetVar("newName", newName1);
I'm attaching a sample story file with the javascript code I'm using.
3 Replies
Hi Shipra, the following code is valid:
Hi Sam, Thanks for replying but its not working! (I replaced my js code with the above)
Hi Shipra, have you tried opening up the browser console and accessing the values directly using the method above, or place some output from your script using console.log.
This discussion is closed. You can start a new discussion or contact Articulate Support.