Hi All,
There is an interesting JavaScript that i found while using the javascript code in webpart or any aspx page that you are developing for moss or even in master page or anywhere when you require to write a code.
This variable _spUserId is useful to know the ID of the logged in user in javascript.
Just try to login to your site and then go to address bar and then write javascript
javascript:alert(_spUserId); and see what it gives you and try using different IDs.
From there only you will get an idea that it is returning the IDs of the logged in user.
That's it.
SharePoint Kings,Technosavvy guys hunting SharePoint Challenges... SharePoint 2013, SharePoint 2010, MOSS 2007, Windows Workflow Foundation, Project Server and Other Related Technologies.
Subscribe to:
Post Comments (Atom)
Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!
If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com
8 comments:
Cool.. It works thanks
This alert returns '1'. What does that mean?
its id of logged in user
how wud you use the same inside the script??? I tried all the ways without any luk.
kalyan, can explain how you are trying?because we are getting from the above method in moss 2007
Thnx for the quick response,
below are the different ways that I have tried to make use of this variable.
< script lang="javascript" >
alert(_spUserId)
or
var userID = _spUserId;
alert(userID);
or
var userID = javascript:_spUserId;
alert(userID);
< /script >
none of these helped me in getting the ID of the current logged in user except typing in place of URL with "javascript:alert(_spUserId)" which we cant make use of that code in actual scripting.
Please let me know, if I have missed something to use.
kalyan,
it looks like when your javascript is fired at that time it might be possible that ID was not available so try to put your javascript at the end if that was not working try to use
_spbodyonloadfunctionnames.push(yourfunc);
and in try
function yourfunc()
{alert(_spUserId);}
try this it should work if not then it might be something special for your case :(
How about user name?
Post a Comment