Forum Discussion
Getting JSON Data into Storyline?
We deliver our SL Courses on a LMS which hasn't the "normal" SCORM Interface.
Here I want to get the User Name, Course ID etc...
I got from the LMS Developer this code:
-------------
try {
var data = JSON.parse(suspendDataRaw);
var player = GetPlayer();
player.SetVar("user_id", data.userId);
player.SetVar("course_id", data.courseId);
player.SetVar("lesson_id", data.lessonId);
player.SetVar(„userName", data.userName);
} catch (e) {
console.log("Fehler beim Parsen von suspend_data:", e);
}
------------------
But this code doesn't work in my JS-Trigger.
How should this code be, that it works?
Does anybody has a idea or solution?
Thx for your help.
2 Replies
- OlliCommunity Member
Thx for your answer - unfortunately it doesn't work....
- garymoulton-a40Community Member
Try this:
try {
var player = GetPlayer();// Replace this with the actual way your LMS provides suspendData
var suspendDataRaw = window.suspendDataRaw;if (!suspendDataRaw) throw new Error("suspendDataRaw is undefined.");
var data = JSON.parse(suspendDataRaw);
player.SetVar("user_id", data.userId);
player.SetVar("course_id", data.courseId);
player.SetVar("lesson_id", data.lessonId);
player.SetVar("userName", data.userName);} catch (e) {
console.log("Error parsing suspend_data:", e);
}