Javascript for sending Storyline 360 text entries via email

Jun 14, 2022

Within SL, I've been trying to initiate an email via javascript that contains text entry content, but I cannot get it to work. Essentially, I want the learner to be able to send their notes to themselves/others in an email.

I get halfway there: I'm able to generate a new browser tab (via each of the below separate sets of java), but no Outlook email generates. Each of them, when tested separately, only opens a Chrome browser tab.

What am I doing wrong? I need it to generate an Outlook email.

JAVA 1

var player = GetPlayer();
var email='';
var subject='Tracks Course Notes';
var feedback=player.GetVar('MyNotes');
var emailBody = +feedback
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+encodeURIComponent(emailBody);
win=window.open(mailto_link,'emailWin');

 

--------------------------

JAVA 2

var player = GetPlayer();

var useremail=player.GetVar("Email");

var subject="Tracks Training Notes";

var notes1=player.GetVar("MyNotes");

var content="Tracks Training Notes%0d%0A%0d%0A";

content+=notes1;

var mailto_link='mailto:'+useremail+'?subject='+subject+'&body='+content;

win=window.open(mailto_link,'emailWin');

 

-------------------------------

JAVA 3

var player = GetPlayer();
var email=player.GetVar("Email");
var subject="Tracks Training Feedback";
var body_start=player.GetVar("MyNotes");
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+escape(body_start);
emailwin=window.open(mailto_link,'emailWin');
emailwin=window.close();

13 Replies
Shamina Christian

Hi Maria! For some reason, I can't see your screen recording - can you try uploading it again? I'm trying to do the same thing as Shae, and it'd be great to figure this out. :) I've added my current .story file so you can see the JavaScript in there (I know nothing about JavaScript!).

Thank you!

Maria Costa-Stienstra

Hi, Shamina.

Thank you for letting me know! I fixed the link, and you should be able to see the screen recording now. 

Since I'm not very knowledgeable in Javascript, and it's not something we support, I'll leave it for our community members to chime in. However, I noticed your code referenced variables that were not in your project. 

I changed a few things, and it looks like it's working now. I'm attaching the .story file here.

I hope this helps!

Janet Minchella

Anyone know how to make this javascript open in Outlook so learners can ask questions?  Here is my current JS

var player = GetPlayer();
var email='';
var subject='VCI Complaint Management Question';
var feedback=player.GetVar('MyQuestion');
var emailBody = +feedback
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+encodeURIComponent(emailBody);
win=window.open(mailto_link,'regulatorytraining@vwcredit.com');

Sara Collister

Hi, I'm able to bring over the text entry into the email body but it loses all formatting and merges into one long line of continuous text. Does anybody know how to bring over the formatted texts/keep the paragraphs?

Any help is appreciated. TIA :) 

My current JS - 

var player = GetPlayer();
var email='';
var user = player.GetVar("UserName") ;
var text = player.GetVar("TextEntry") ;
var subject = "Journal Exercise Notes" ;
console.log("mailto: "+user+" | "+text)
var emailBody = player.GetVar("TextEntry");
var mailto_link = 'mailto: '+email+'?subject='+subject+'&body='+emailBody;
win = window.open(mailto_link, 'emailWin') ;