execute javascript in trigger does not work in Sharepoint 2013

Jun 27, 2014

We have designed a certificate of completion using javascript to get the current date as outlined on this forum, but it is not working within our SharePoint environment where the content is hosted.  It works properly locally(View after publish to web/lms as well as publish to CD), and in an LMS environment (reviewmyelearning.com), but when I publish for web and transfer the storyline output files to SharePoint 2013 (SSL connection), the date is not displayed (no error message). I had similar results trying to use other javascript functions (print does not open the dialog box, exit course does not close the window, no visible error messages generated) in storyline triggers within the sharepoint environment. 

Any suggestions as to why these functions would not work in that environment only?  Other storyline functionality appears to be working as expected.  Is execution of functions in the user.js a capability that would need to be enabled in the sharepoint configuration? 

8 Replies
Mary Mascari

I'm having the same problem. I know that you can't run JavaScript inline on a page in SharePoint 2013. If you want to run a JavaScript, you have to put the script in a separate text file and call it from there.  

I suspect that those issues are related.

Is there a way for the Storyline project to call a function in a separate JavaScript file? That would probably be a workaround. 

Mary Mascari

As I suspected, it's SharePoint 2013. If I embed JavaScript in the trigger, SparePoint strips it out. However, if I put the code in a function in a separate .js file and call that function in the trigger, it works fine.

You need to add a reference to the .js file in the story.html file, too. Instructions for how to do that are here: https://community.articulate.com/discussions/articulate-storyline/articulate-storyline-external-links-easy-javascript-file-containing-the-links 

Mary Nagy

I am also having trouble using JavaScript with SharePoint 2016. Has anyone experienced this and found a solution?

Clicking a button in our course, executes the JavaScript function:

TravelersBBPDocument().

It is defined in a document on our SharePoint site as:

function TravelersBBPDocument()

{

window.open("https://collaborate.dealertire.com/People/DistributionCenterTrainingLibrary/travelers-bbp.pdf");

}

The code identifying the document that defines the function is inserted into the story.html file (approximately line 126).

<script language="JavaScript1.2"src="https://collaborate.dealertire.com/People/TrainingDevelopmentLibrary/elearning-course-links.js" type="text/javascript">

</script>

 

This discussion is closed. You can start a new discussion or contact Articulate Support.