Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User actions trigger data pushed to file

Status
Not open for further replies.

EdwardMartinIII

Technical User
Sep 17, 2002
1,655
US
I'm pretty new to SP, so simpler explanations might help. 8)

We have a Sharepoint site. It contains an HTML file, a menu of links. Each link either goes to a PDF file somewhere else on another server, or another kind of file (a training file).

For example:

Repairing the Fuel Line
These instructions cover repairing the fuel line throughout the entire vehicle.
* Link to Training
* Link to PDF

What I would like to do is collect user data whenever a user clicks one of those links. The data I want to collect is the user ID (or some other method of identifying the user), and which link they clicked, and the date/time.

I'd like to collect that data into a file on the Sharepoint site.

For example, the file might contain (where EMAR is my user ID):

Code:
March 16, 2012 - 9:25:00am - EMAR - Repairing Fuel Line (Training)
March 16, 2012 - 9:31:14am - EMAR - Repairing Fuel Line (PDF)
March 16, 2012 - 9:45:00am - EMAR - Repairing Fuel Line (Training)

Is that even possible?

I'm assuming I'd put a big onClick action at each link (which is fine), but I wouldn't know how to create the data string, open the file, append the string to the file, and then close the file.

Advice, pointers, etc. would be very, very welcome!

Thanks!



[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
I'm assuming I can use JavaScript and an onClick action to do the processing.

Is it possible to collect a user ID of some sort automatically, or will I need to depend on, say, some form of JavaScript query window that collects that data?


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Before I cam here, each link bounced to a tiny "login" page. That login page had you fill in your user ID and press a [Continue] button. The action of that form pushed the form contents (and some other data) out to a document on Google Docs.

Discovering this has kinda wigged out my supervisors (it's a big enough company that although people knew the information was being collected, no one knew WHERE it was being collected), and they've asked me to figure out a way to collect the same information internally, instead of relying on a Google Doc on someone's personal site.


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
First pass to see if I can properly build the data string:

Code:
<script type="text/javascript">
<!-- hide script
 function DataStash(LinkName) {
   var DataString = "Date: " + Date() + ", Function: " + LinkName + ", User: " + prompt("Please enter your user ID: ","First and Last Name");
   alert(DataString);
 return 0;
}
// end hiding -->
</script>

I would rather be able to somehow query to determine the UserID automatically. Surely if I'm logged onto a computer or logged into Sharepoint, there's some sort of user ID for which I can poll...?

From here, I'll try to move on to opening and appending to a file in Sharepoint.


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Okay, so far, this seems to work, but with the following caveats:

1. The file (as shown in the code below) is written to the desktop. I would expect to put the entire Sharepoint location in the OpenTextFile command, which means (I think) that the write permissions to the Sharepoint directory will be the same as the person viewing the file, which means that I must make sure that everybody has write access.

2. Can only work in IE.

3. User still has to manually input their name. Is there any way to query the user's login automatically?!

Code:
<script type="text/javascript">
<!-- hide script
 function DataStash(LinkName) {
   <!-- Build the DataString -->
   var DataString = "Date: " + Date() + ", Function: " + LinkName + ", User: " + prompt("Please enter your user ID: ","First and Last Name");
   <!-- alert(DataString); Just some test code to make sure I formatted the string properly -->
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var s = fso.OpenTextFile("DataAccess.txt", 8, true,0);
   s.WriteLine(DataString);
   s.Close();
 return 0;
}
// end hiding -->
</script>

[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Aaaaaaand Supervisor just put the project on long term hold.

Oh well...


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top