Course Name variable (for SmartSheet)

Goal:  Prefill in as many fields as we can for users on a SmartSheet survey form at the end of our University courses (100s of courses will be updated with this new feature).

I am using JS to extract the UserID and UserName.  This is working.

QUESTION:  Is there already an existing easy way to extract the coursename from already designed courses?   

 My current (ugh) plan is to edit each course, create a variable where I manually add the course name.  Then my already constructed JS will create the smartURL that the user will be given at the end of the course that will prefill in the fields as the form opens.

I would love to just drop in the new javascript without having to manually add in course-specific variables.

Any brilliant paths to that goal?   Thanks in advance.

3 Replies
Jerry Beaucaire

My final code, for your reference:

//Put name of student into variable "username"
//Construct a URL with the student's name included in variable "smartURL"

var feedbackform = ""
var player = GetPlayer();
var docname = document.title

function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;

else if (win.parent == win) return null;

else return findLMSAPI(win.parent);

var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + '%20' + array[0];
player.SetVar("username", array[1]);

if (newName) {
player.SetVar("smartURL", feedbackform + "?Name=" + newName + "&Course=" + docname);
player.SetVar("smartURL", feedbackform + "?Course=" + docname);

And here is the JS that is connected to the FEEDBACK button in the course

//Open the smartURL link created earlier
var player = GetPlayer();
var win ="smartURL"));