[Help] Adding a New Item on Sharepoint Custom List using Javascript in Storyline 2

Dec 16, 2016

Hi guys, can you help me with this. we dont have an LMS as of the moment but we still want to track those people that will take the course. one way is to create a button on the end of the course that execute's a javascript that will add new item on a specific list in sharepoint  "Name,Course and time and date", i create a variable text in storyline 2 name "nameSL" and "CourseSL" this will be passed on to a javascript trigger via a button and add the new information" 

Sharepoint Columns - Storyline variable

Name - nameSL

Course - CourseSL

Time and Date - systemdate

 

here is the code im working on, can anyone help me with this. because when i tried to execute it, it doenst do anything

 

var siteUrl = 'sample.sharepoint.com/AMS/Lists/AmsTrack';

function updateListItem() {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=month + "/" + day + "/" + year
var player = GetPlayer();
var nameSL = player.GetVar("Name");
var CourseSL = player.GetVar("Course");
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Announcements');

this.oListItem = oList.getItemById(3);

oListItem.set_item('Name', nameSL);
oListItem.set_item('Course', CourseSL);
oListItem.set_item('TimeDate', datestring);
oListItem.update();

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {

alert('Item updated!');
}

function onQueryFailed(sender, args) {

alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

2 Replies

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