Javascript not working when published to Tempshare

Hi everyone,

I've been using this script below to capture some free text responses etc.

If I publish the file and open the .story file, it asks for permission to run ActiveX which is absolutely fine, then it does what I need it to do and writes to a txt file on my network.

However, when I upload the files to Tempshare or our own browser, it doesn't work. The javascript doesn't seem to run or create the txt file.

Any ideas?

 

var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.OpenTextFile("T:\\HR\\Folder\\SubFiolder\\Sub Folders\\results.txt", 8, true, 0);
var player = GetPlayer();
var name = player.GetVar("Username");
var text = player.GetVar("TextEntry1");
var email = player.GetVar("TextEntry2");
var box = player.GetVar("TextEntry3");
s.WriteLine("First name: " + name);
s.WriteLine("Surname: " + text);
s.WriteLine("Answer 1: " + email);
s.WriteLine("Answer 2: " + box);
s.WriteLine("==========");
s.Close();

Thanks,


Marc

1 Reply
Dave Cox

It may be that you don't have write permissions on that location.

try replacing your script with this:

var fso = new ActiveXObject("Scripting.FileSystemObject");
console.log("var fso created");
var s = fso.OpenTextFile("T:\\HR\\Folder\\SubFiolder\\Sub Folders\\results.txt", 8, true, 0);
console.log("file opened");
var player = GetPlayer();
console.log("var player created");
var name = player.GetVar("Username");
console.log("var name created");
var text = player.GetVar("TextEntry1");
console.log("var text created " + text);
var email = player.GetVar("TextEntry2");
console.log("var email created " + email);
var box = player.GetVar("TextEntry3");
console.log("var box created " + box);
s.WriteLine("First name: " + name);
console.log("First name written " + name);
s.WriteLine("Surname: " + text);
console.log("surname written " + text);
s.WriteLine("Answer 1: " + email);
console.log("Answer 1 written " + email);
s.WriteLine("Answer 2: " + box);
console.log("Answer 2 written " + box);
s.WriteLine("==========");
console.log("========== written");
s.Close();
console.log("file closed");

When you first open your project in your browser press F12 to open the debug window. Select the console tab.

When you get to this script, all of those console statements that I added will start writing to the console. Where is stops is where you trouble lies. Once javascript encounters an error, it stops running and does not process the remaining statements.