Forum Discussion
Send results slide via email using Javascript ??
Hello! I'm pretty new to... well... all of this, but I'm a fast learner. I've been toying around with adding Javascript to my Storyline project for some advanced capabilities, and so far I've figured out how to execute an email with HTML5. I understand that there are issues with mobile and Flash.
So my question is: is it possible to set up Javascript within my Storyline project that will email an image of the results slide/certificate of completion?
It would be great if the image could be in the body of the email, but I would also be happy if it were an attachment. I don't know if it is possible to set it up so that once the user lands on the results/completion slide, there is an image automatically generated and included in the email.... again, pretty new at this. =)
Here is my current set up (for my test project) including code:
- I set up a text entry called "EmailAddress" - the user will enter their desired email addresses in here.
- I have a text variable called "EmailAddress"
- I added a trigger to a button that will execute Javascript when the user clicks.
This is the Javascript I'm using:
var player = GetPlayer();
var course="Storyline test course"
var email=player.GetVar("EmailAddress");
var subject="Assessment Complete";
var body_start="I've just completed my assessment!";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');
Please note: I've patched my JS together from information I've found within these forums and on the web. I don't know how to write JS or all the rules, but I can usually figure out how to use it if I play around with it for long enough.
Any help would be amazing, and thank you so much in advance... and sorry if this question has already been covered; I wasn't able to find an answer anywhere. =)
30 Replies
- TravisSmith1Community Member
Hello,
Your JavaScript is wrong. You are missing a semi-colon from the end of the var course... statement, which you don't use so you can just delete it.
----
var player = GetPlayer();
var email=player.GetVar("EmailAddress");
var subject="Assessment Complete";
var body_start="I've just completed my assessment!";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');- VandanaPa-fcf58Community Member
Hi Travis,
I tried to use this code but it's not working for me. Could you please help.
- AnaVictóriaCommunity Member
Hello,
I need something similar but the email has to have a little more text. I have the following text variables:
- Commitment
- Name
- ManagerEmail
I edited the above jc to nomething like this:
var player = GetPlayer();
var email=player.GetVar("ManagerEmail");
var nome=player.GetVar("Name");
var texto=player.GetVar("Commitment");
var subject="My Corporate Responsibility Commitment";
var body_start="Dear Manager, "+nome+" has sent you his/her Corporate Responsibility Commitment:";
var body_end="Please discuss this commitment with "+nome;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start +texto +body_end;
win=window.open(mailto_link,'emailWin');Will it work? is it possible to have in the '&body' ?
Thanks !!
- TravisSmith1Community Member
Hello Ana,
Yes, you can do that, but to add formatting you may need to do something a bit different.
Try this: https://gist.github.com/wpsmith/5221305
Thanks,
Travis
- SamClarkCommunity Member
Travis Smith said:
Try this: https://gist.github.com/wpsmith/5221305
I ran into clients that didn't have email applications on some of the workstations, and other situations where workstation mis-configuration didn't invoke the email application at all. Because the workforce was so large, addressing all the exceptions was not possible.
To solve the problem I developed a server-side email solution which allowed learners to do form-entry email in the course via a web object. It sends email reliably, but it requires setup of a server-side script which requires a lot of cooperation with both LMS and server administration. Installing private or course-specific scripts is a major issue that many LMS installations won't support.
LMS server scripts could be avoided by having the course reference a 3rd party email solution but many installations would see this as a security violation, or would it? I understand courses reference youtube videos which are 3rd party, but those aren't executable scripts.
Does anyone have a story of how reliably reference 3rd party services, or how to implement email feedback using 3rd party services or... something out of the box?
- LaytonFCommunity Member
Hello Alicia,
Did you ever figure out the answer to your question? I am hoping to setup something similar. I have done something similar in the past using Captivate and a third party widget but haven't been able to duplicate the same procedure using Storyline. Based on your original post you seem to be quite close to a solution using javascript. Any insights that you can share would be greatly appreciated.
Regards,
- JohnGriffiths2Community Member
Hi,
This script looks really promising and I would be really interested to know which file you edit to insert it? I have looked under the project / story_content / story.js file but cannot find the right place for it to be.
Any help would be much appreciated.
John
- AliciaSummersCommunity Member
Leyhton F said:
Hello Alicia,
Did you ever figure out the answer to your question? I am hoping to setup something similar. I have done something similar in the past using Captivate and a third party widget but haven't been able to duplicate the same procedure using Storyline. Based on your original post you seem to be quite close to a solution using javascript. Any insights that you can share would be greatly appreciated.
Regards,
Hi Leyhton,Unfortunately no, I was never able to get the Javascript to execute what I needed it to do. I wanted the Javascript to email an image - a certificate of completion. I was able to get Javascript to execute sending an email with the original script I posted above, but I'm not quite proficient enough in Javascript to get it to email an image...or perhaps that's just not a capability at this time.
John Griffiths said:
Hi,
This script looks really promising and I would be really interested to know which file you edit to insert it? I have looked under the project / story_content / story.js file but cannot find the right place for it to be.
Any help would be much appreciated.
John
Hi John,I can't speak for anyone else, but when I add Javascript to Storyline I open up the Storyline file that I'm editing and add a trigger. Select "Execute Javascript" as the action and you'll get a little "..." button right below the action line (for the Script). Click on that button and a blank box will appear. Copy and paste your Javascript into the box and click OK. Then just fill out the When and Object lines as needed. Hope this helps!
- JohnGriffiths2Community Member
Hi Alicia,
Of course! Sorry, brain went to sleep there. I am currently trying to get a similar script to work, albeit not using images but Dennis seems to know a lot about it.
Check out the thread, you might be able to catch a break:
http://community.articulate.com/forums/p/40049/227676.aspx#227676
John
- TravisSmith1Community Member
Sam Clark said:
Travis Smith said:
Try this: https://gist.github.com/wpsmith/5221305
I ran into clients that didn't have email applications on some of the workstations, and other situations where workstation mis-configuration didn't invoke the email application at all. Because the workforce was so large, addressing all the exceptions was not possible.
To solve the problem I developed a server-side email solution which allowed learners to do form-entry email in the course via a web object. It sends email reliably, but it requires setup of a server-side script which requires a lot of cooperation with both LMS and server administration. Installing private or course-specific scripts is a major issue that many LMS installations won't support.
LMS server scripts could be avoided by having the course reference a 3rd party email solution but many installations would see this as a security violation, or would it? I understand courses reference youtube videos which are 3rd party, but those aren't executable scripts.
Does anyone have a story of how reliably reference 3rd party services, or how to implement email feedback using 3rd party services or... something out of the box?
Yes, this would be a huge security issue. Depending on the server setup, you may be able to do a Gmail API integration, but you would need access to the MX records, PHP configuration access (php.ini), etc. which I highly doubt any one would ever give you. There is only so much one can do within a course.
- TravisSmith1Community Member
John Griffiths said:
Hi,
This script looks really promising and I would be really interested to know which file you edit to insert it? I have looked under the project / story_content / story.js file but cannot find the right place for it to be.
Any help would be much appreciated.
John
It would go within the course, Execute JavaScript or possibly in the user.js file.