Please Help me with Java Code

Apr 29, 2014

I am trying to email from Storyline with the below code.  It is working perfectly but how can I get my variables from Storyline into my email body?  I would like the body of my email to read:

"Name (Variable from Storyline)" from "Command (Variable from Storyline)" has completed the CO's Annual FAP Refresher eLearning Course. 

THANKS!!!

var email="alicia.k.durham@usmc-mccs.org";

var player = GetPlayer();

var name = player.GetVar("Name");

var command = player.GetVar("Command");

var subject="COs FAP Refresher eLearning Course";

var body_start= "has completed the CO's Annual FAP Refresher eLearning Course.";

var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;

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

6 Replies
Nicole Legault
OWEN HOLT

Alicia Durham said:

...

var email="alicia.k.durham@usmc-mccs.org";

var player = GetPlayer();

var name = player.GetVar("Name");

var command = player.GetVar("Command");

var subject="COs FAP Refresher eLearning Course";

var body_start= "has completed the CO's Annual FAP Refresher eLearning Course.";

var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;

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


Try adding all of the variables and content into a single java variable and then use that for your body. Something like this:

var player = GetPlayer();

var email="alicia.k.durham@usmc-mccs.org";

var subject="COs FAP Refresher eLearning Course";

var name = player.GetVar("Name");

var command = player.GetVar("Command");

var body=name+" from "+command+" has completed the CO's Annual FAP Refresher eLearning Course.";

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

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

Vasily Ingogly

Point of clarification: Java is a compiled programming language developed by Sun, and Javascript is an interpreted scripting language developed by Netscape. Javascript was chosen as a marketing ploy; Netscape licensed the Java trademark from Sun because Java was popular at the time.

Other than the trademark and both offering object oriented features, the two have nothing to do with each other. In many forums, if you ask a "Java" question, the first reply is likely to be: "are you talking about Java or Javascript?"

OWEN HOLT

I haven't used window print directly. Typically, I'm doing the following:

1) opening a new window with: myWindow = window.open("","Print","width=900,height=700,scrollbars=0,resizable=0");

2) building content for it with java and html: var content ='........'  and content+='......'

3) Writing the content to the new window: myWindow.document.write(content);

4) Notifying the window that it has everything: myWindow.document.close();

5) Making sure the new window has the system's focus: myWindow.focus();

6) Executing the print command for the new window: myWindow.print();

This has worked for me in both I.E. and Chrome.

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