Java Script help needed!
Mar 31, 2021
Hi Everyone,
I need help with some JS - I'm very new to it and struggling a little.
Background: I have a storyline built and want to have the option for learners to email their various text entries to a third party who will score them.
This is the JS I'm trying to use:
var player = GetPlayer();
var useremail=player.GetVar("Emailaddress");
var subject="Consolidation 1 Results";
var FirstName=player.GetVar("LearnerName");
var Surname=player.GetVar("LearnerSurname");
var ECNumber=player.GetVar("StaffID");
var Scenario1greet=player.GetVar("Scenario1greet");
var Scenario1End=player.GetVar("Scen1End");
var Scenario2greet=player.GetVar("Scenario2greet");
var Scen2response=player.GetVar("Scen2response");
var Scenario2End=play.GetVar("Scenario2End");
var mailto_link='mailto:'+useremail+'?subject='+subject+'&body='+"Learner Name:%0d%0A"+FirstName+""+Surname+"
%0d%0A%0d%0ALearner Staff Number:%0d%0A"+ECNumber+"
%0d%0A%0d%0A'+"Scenario 1 – This is how I would greet the customer:%0d%0A"+Scenario1greet+"
%0d%0A%0d%0A'+"Scenario 1 – This is how I would finish the conversation with the customer:%0d%0A"+Scen1End+"
%0d%0A%0d%0A'+"Scenario 2 - My greeting to the customer:%0d%0A"+Scenario2greet+"
%0d%0A%0d%0A'+"Scenario 2 – My response to the customer:%0d%0A"+ Scen2response+"
%0d%0A%0d%0A;'+"Scenario 2 – End of conversation with the customer:%0d%0A"+Scenario2End+";
win=window.open(mailto_link,'emailWin');
Is anyone able to point out where I'm going wrong and how to fix it?
5 Replies
What do you mean by going wrong? What do you want it to do, and what is it doing instead?
Here is a discussion with a couple of scripts that work, that may help you:
https://community.articulate.com/discussions/articulate-storyline/email-trigger-6b23ebd8-5867-45a1-878f-a14f25c9f66a#reply-670792
Hi Walt,
The JS is attached to a trigger which should populate an email when the user interacts with it.
At the moment nothing happens so I'm assuming there is a mistake in the script itself.
Thanks for the link to the discussion - it's given me some ideas!
Have you checked the console to see what errors you have?
Have you run that code through a text editor like Atom, looking at it I think you have quite a few syntax errors
And a sample of your project might help too. Most of us don't have the time to create sample projects with code shown...but if its something simple thats wrong...a sample Storyline might be fixed in minutes.