Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Function $().SPServices.SPGetCurrentUser not working

$
0
0
Hi.

I am new in developing in Sharepoint and I want to get the UserID of the user who is loged in. This UserID i want to put at the end of a hyperlink, so that it is a dynamic hyperlink for every user. But if i run the following code, I only get an alert("hello") which is at the top of the script. everything after that, is not running.
I put this code in a masterpage of Sharepoint and it doesn't work.
I am using Sharepoint 2013 and SPServices 2013.01. The JQuery Version is 1.8.3.

Here is the Code i am using:
<script src="JavaScripts/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="JavaScripts/jquery.SPServices-2013.01.min.js" type="text/javascript"></script>
<script type="text/javascript">
alert("hello");             
var thisUserAccount = $().SPServices.SPGetCurrentUser({fieldName: "ID", debug: false});
alert(thisUserAccount);
var link = document.getElementById("myDocuments");
alert("[URL]" + thisUserAccount);
                                
link.href = "[URL]/" + thisUserAccount;
                            
var link2 = document.getElementById("myTasks");
link2.href = "[URL]" + thisUserAccount + "AllTasks.aspx";
                            
</script>
thank you for your help!

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>