22 Replies
Chris Purvis

Hi there I found this which should help

http://community.articulate.com/forums/t/32288.aspx

var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear();
var player = GetPlayer();
var newName = day + "/" + month + "/" +year
player.SetVar("DateValue", newName);

DateValue is my variable in the storyline, it should be a text value

Rebecca Fleisch Cordeiro

Did you see this Articulate support page on Java Script Best Practices? It includes some content plus a link to a (very good) Brian Batt Screenr on how to insert the current date. I've used it in the past and it's worked for me.

It also includes the JavaScript command for printing the current slide:

Print current slide

window.print();

And here a link to a thread with more info on Printing Certificates.

Jeffrey Riley

I followed the information here and specifically the steps on the this Articulate support page but I cannot get this to work. After I publish the file the slide is blank. I never see the date information. I am not sure what I have done wrong but something is missing, I hope someone can help. The dropbox link below should have the storyline file.

DropBox

Rebecca Fleisch Cordeiro

Hi Jeffrey,

Are you publishing locally? Security restrictions can cause some things to fail when publishing locally.

Can you try publishing to a web server or your LMS, if you have one? Or, if publishing locally, try publishing to CD. Here's a support page with helpful information, including places where you can test published output.

OWEN HOLT

you need to use an array with the month names. The JavaScript code below created both formats.

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

//get the name of the month
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var currentMonth = month[today.getMonth()];
//create the alternate date as mmmm dd, yyyy
var alternateDate = currentMonth + " " + dd + ", " + yyyy;

//create the standard numeric date as mm/dd/yyyy
//start by creating a leading zero for single digit days and months
if(dd<10) {
dd='0'+dd
}

if(mm<10) {
mm='0'+mm
}

today = mm+'/'+dd+'/'+yyyy;

//send the dates to StoryLine variables
var player = GetPlayer();
player.SetVar("SystemDate",today);
player.SetVar("AlternateDate",alternateDate);

Ron Lutka

Thank you, Owen. We will likely go with creating the certificates in PPT and saving them as pdf then emailing them. That is technology I understand.

For future reference I did try to copy and paste all the JavaScript you supplied into my variable then I published but could not get it to work. FYI, I know nothing about JavaScript.