JS/Storyline help - Commit(); status

Hey everyone, 

I'm trying to put together an alert if the SCORM 2004 package fails to communicate with the LMS. 

This seems easy enough and it strikes me that all the pieces are there, but I'm struggling to assemble the pieces into something that works, on account of I have only just started messing with JavaScript.

Let's pretend this is called when a user clicks an object, and the alerts (one for success, one for failure) are on layers. There's a piece in italics that I'm not sure about. Can anyone help me flesh this out? Seems like it might be useful to lots of folks.

Thanks in advance!


Trigger 1 (to make sure the player is got, commit, & return status of commit call to player)

Execute JS:

var player = GetPlayer();


Record response, either True or False, to JS variable commitstatus

player.SetVar("CommitStatus", commitstatus);

Trigger 3 (show alert - successful)

Show layer Success when user clicks if CommitStatus is equal to True.

Trigger 4 (show alert - successful)

Show layer Failure when user clicks if CommitStatus is equal to False.


1 Reply
Russell Killips

Hi Trevor,

I have done something like this before but it was only a message for when it failed.

1. Create a Text Variable in Storyline called CommitStatus with Unknown as the default value.

2. Have a trigger on the master slide to show the Failure Layer when the CommitStatus variable changes if CommitStatus = "False".

3. After publishing the course. I needed to modify a function in the SCORM2004Functions.js File.
The specific function is SCORM2004_CallCommit()

I added 3 lines of code.

At Line 2235: var player = GetPlayer();

At Line 2262 (just before the return false): player.SetVar("CommitStatus","False");

At Line 2269 just before the return true): player.SetVar("CommitStatus","True");

Here is a picture of the function with my changes.

Commit Function