Storyline 360: Unable to fetch user name from LMS using javascript

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