Setting an expiry date for published content

Jan 30, 2013

Hi there.

As the title says, I was wondering if there was any way to set an expiry date for published content, which would basically stop users from being able to view the content after a specific date? I've used this feature in KnowledgePresenter before but can't find such a thing anywhere in Storyline.

It would be very handy, as we are basically looking to put our course on disc to send out to people to trial them, but we don't want them having access to our courses beyond the trial period.

Thanks again for any support on this.

81 Replies
Will Grasse

Our clients require an expiration date on their courses. We were a Captivate shop and this feature is built into the Publish Settings. But we recently started using Storyline exclusively and are only now realizing that there is NO expiration date that can be set for published courses. We are hoping there will be an upgrade including this soon or a workaround that is compatible with multi-platforms and mobile media as well.

Rachel Horton

Hi Zio,

Thank you for sharing your solution. I had it working in past versions of SL. It stopped working. Any ideas as to why? 

When the "yearexpire" is set in the future I receive the Valid Layer as designed.

When the "yearexpire" is set in the past, I do not receive the Expired Layer.

Are you still using Storyline? Which version? I am using Storyline 360 v3.34.20804.0.

Any help would be much appreciated.

Thank you.


Let me simplify the process and code for you.

You need 3 variables:

  • 1 text for a "published" or "created" date in the format of mm/dd/yyyy
  • 1 number variable for the number (in days) that the course is valid for, like 60 or 365
  • and one numeric variable (let's call it "Days") that will receive a value from the JavaScript below showing how much time has passed sine the course was published/updated

You need to execute the following JavaScript at TimeLine start on your first slide.

let player = GetPlayer();

var date1 = new Date(player.GetVar("CreationDate"));
var date2 = new Date();
var elapsedTime = date2.getTime() - date1.getTime();
var elapsedDays = elapsedTime/(1000 * 3600 * 24);

player.SetVar("Days", elapsedDays);

Lastly, you need a trigger to run AFTER the Javascript to show your "Course Expired" layer. It should be something like Show layer Expired when timeline starts if Days > Valid_Days

You can see it in action here: Link to Demo

If that is what you you are looking for, there is a Template file in the resources of the published course that you can download.

Rachel Horton

Thank you Owen. I wish I could say I understand completely. I have a few questions. 

The outcome I want is to have the expired layer display upon expiration of the content lease which is typically 1 year/365 days.

1. I created a text variable with the name "CreationDate". Is this the correct name I should use? Would the date be the date the lease starts? For example, if the lease begins today I would enter 02/10/2020.

2. I created a number variable with the name "Valid". I entered the Default Value as 365. Is that correct?

3. I don't know what the 3rd variable should look like. What should the Name be? Is it a number variable? Does it need to be a variable name that is already part of the javascript? What is the default value?

I've attached a test course which includes the variables and triggers. I have the Show Layer Expired trigger built. However, I don't know what to add for the Conditions.


Answers to your questions and some additional information about the code.

  1. Yes, that is the name I used for the variable and YES you understand it correctly. A lease that began at the start of the year would be 01/01/2020 or a lease starting today would be 02/10/2020.
  2. "Valid" will work for the variable name.  In my example I think I used "Valid_Days". This is a numeric value and you are, again, exactly right; it represents the number of days from the start that the course is valid (or open) for.  For 1 year, you would use 365.
  3. I called my 3rd variable "Days". This is a value calculated by the JavaScript that represent hw many days have passed since the date stored in the "CreationDate" variable.

How the JavaScript works:

  1. The 1st thing the script does is create a connection to the StoryLine player and stores it a JS variable labeled "Player".  let player = GetPlayer();
  2. Next, the script pulls the creation date from StoryLine and stores it in a JS variable called date1.  var date1 = new Date(player.GetVar("CreationDate"));
  3. The script then pulls the current date from the computer and stores it in a variable called date2.   var date2 = new Date();
  4. When performing math functions with dates, it is easiest to work with the date as a single numeric value stated in a time value. var elapsedTime = date2.getTime() - date1.getTime();  converts both date variables into a time value in milliseconds and subtracts one from the other.
  5. The result of the above calculation will be a number in milliseconds representing the difference between the 2 dates so var elapsedDays = elapsedTime/(1000 * 3600 * 24); converts the value back to a number representing days.
  6. player.SetVar("Days", elapsedDays); sends the value back to StoryLine.
  7. Once you have the calculated variable, you still need a trigger to compare the value of days that have past versus days the course should be active and display the expired layer if the elapsed time is greater than the allowed time.

See it in action here and download the template from the resources in the published course.

Crystal Klarich

I would also love to see expiration dates built into the software, as we sell our courses to people for use on their own LMSs. While it would be lovely to have everyone manage the expiration on their own LMS, it does not make practical business sense.

I was able to get Owen's code to work with a small tweak. I kept getting an infinite loop error and slides were taking forever to load with the code written as it is above. I added stop() at the very end of the javascript and it works perfectly now. The only other change I made was to add a 1 second delay for when the jump to the "expired" slide trigger happens, because I couldn't get the trigger priority to work for some reason. I didn't spend much time exploring that issue, as we actually preferred the look of it. It made the expiration effect a little more pronounced.

Thanks for the help!

Peter Ward

Owen Holt, would you be willing to help with some custom Java script for a Storyline course? In addition to creating an expiration date, we need to be able to set a cap on the number of users. If you're willing to assist, please contact me at We're happy to compensate you for your time.

On another note, it's incredible that Articulate hasn't fulfilled this request after NINE YEARS!

Peter Ward

Following up here to say that Owen Holt (see previous post) was able to update my Storyline file with Javascript and I'm now able to adjust a couple of variables to set an expiration date each time I publish SCORM files for a client. He's willing to help others as time allows, so feel free to reach out to him on LinkedIn for assistance.