Condition/Variable Based on Calendar Year

Dec 17, 2020

Good afternoon,

I have a client that wants certain slides to show based on calendar year, so that a learner would see certain slides in 2021 and different slides in 2022. Has anyone had experience doing this or tell me how it can be done? Thanks in advance!

1 Reply
Dave Cox

Hi Perinda

Yes, you can do that. 

The hard part is getting the year into a variable. To do that, create a text variable. I called mine "Year"

Then you need to run some javascript to get the current date from the system, and set the variable to the current year. The following code will do the trick:

var player = GetPlayer();
var d = new Date();
var y = d.getFullYear();
player.SetVar("Year",y);

Then you can do whatever you want with the value in the variable with your triggers. In my example, I'm just displaying it on the slide.

Regards,

Dave