Launching email with variables in Storyline
Oct 05, 2016
My course contains two question blocks. On the final results page, the result score for each question block is displayed. The Send Email button uses the following JavaScript code:
Player = GetPlayer();
var SendEmail = Player.GetVar("SendEmail");
var Subject = Player.GetVar("EmailSubject");
var Linux.ScorePercent = Player.GetVar("Linux.ScorePercent");
var Virt.ScorePercent = Player.GetVar("Virt.ScorePercent");
var sBody = "Here are your results " + "\r\n";
sBody += "Linux OS " + Linux.ScorePercent + "\r\n";
sBody += "Virtualization " + Virt.ScorePercent + "\r\n";
sBody = encodeURIComponent(sBody);
window.location.href = "mailto:" + SendEmail + "?subject=" + Subject + "&body=" + sBody;
However, nothing happens when I hit the Send Email button in the browser.
Is my Javascript incorrect? Is there something else that I'm missing?
6 Replies
The "mailto:" function requires a mail client (e.g. Outlook, Thunderbird, Apple Mail) on the student's system. The code won't run without this software. I create special data capture web pages that your "email" by Web Object inside SL for just this reason with similar javascript
Our organization uses Outlook as our mail client, so that's not the issue.
When I tested the 'Launch new email message' javascript code on the Best Practices page, that works. It's when I started messing with the code that the trouble starts. :/
You can't access Linux.ScorePercent and Virt.ScorePercent directly.
I created 2 new variables and on the results slide I have triggers that assign the score to them.
Then I updated your script to reference the new score variables.
Russell,
Thank you so much!
Can you tell my why we are unable to access the Storyline-generated variables directly? That will give me the last piece of this puzzle.
Sorry, I don't know why.
Hi Claudine!
This discussion is closed. You can start a new discussion or contact Articulate Support.