Completing a URL with a variable

Mar 10, 2014

Hello,

I'm working on a project in which I would like users to type in their employee ID to access a personalized report via URL. Let's say my employee ID is 1234 and my URL is something like www.company.com/report/userID=1234.pdf.

I would like the user to enter their employee ID at the beginning of the course, then use that variable to fill in the "1234" portion of the URL above.

I'm a javascript novice, but I I'm pretty sure it can be done. It seems like it is possible using the player.GetVar method mentioned in the JavaScript Best Practices. Any ideas?

Thanks,
Matt

7 Replies
Matt Galbraith

I just visited with a colleague who answered my question.

Originally, I was using a text variable named "UserID" in Storyline to capture the employee ID and my code looked like this:

var player = GetPlayer ();

window.open("http://www.company.com/report/user=" + player.GetVar (UserID)+ ".pdf");

This wasn't working because JavaScript can only insert JavaScript variables into the window.open line.  So I needed to use the Storyline variable to define the JavaScript variable (which I named "number"), which looks like this:

var player = GetPlayer();

var number = player.GetVar ("UserID");

As you may have noticed, I also forgot to include the quotation marks around my Storyline variable in the original code. Now that I have created a JavaScript variable, I can insert it in the window.open line.  The full code looks like this:

var player = GetPlayer();

var number = player.GetVar ("UserID");

window.open("http://www.company.com/report/userID=" +  number + ".pdf");

This worked for me. I hope this helps someone else.

Richard Ludwig

Thanks Walt! That makes sense then.

I am using Articulate Online and need to send quiz results to an app outside AO. I was hoping to pull either the email address or the user ID once the user arrives at the results slide to be able to map quiz results to the correct user in the app.

Do you know if the user information can be retrieved from the course module?

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