Execute Java trigger
Jun 04, 2014
Hi, I am trying to use java to update my CRM when certain conditions are met within storyline. eg when someone passes a quiz.
I am using a service that interfaces into my CRM via API and they have supplied the following javascript to perform the activity I need it to. (I have replaced some of the data with X's before pasting here)
http.get("https://XXXX.novaksolutions.com/easy_api/QuickOperations/addTag?key=XXXXXXXXXXXX&tagId=562&createTagIfItDoesntExist=FALSE&ContactId=29546", function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
When I copy this into a trigger and then publish the course to the web the script doesnt seem to run as the desired result is not achieved.
Is there any other text I need to include with the above script in the Execute Java trigger?
Thanks
2 Replies
Hi Adam,
I'm not a javascript expert, so I won't be able to spot anything wrong in the script you provided - but I did want to share that these Javascript best practices and a reminder that you'll want to test the course within the intended publish environment to ensure everything works as expected.
http.get isn't a javascript method. Perhaps they have a library that supports this method. It looks like you want to execute an AJAX call to prevent page refresh. You may run into cross-domain issues with the callback on some browsers unless the API address and content are in the same domain. Here's something that might work:
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",""https://XXXX.novaksolutions.com/easy_api/QuickOperations/addTag?key=XXXXXXXXXXXX&tagId=562&createTagIfItDoesntExist=FALSE&ContactId=29546",true);
xmlhttp.send();
This discussion is closed. You can start a new discussion or contact Articulate Support.