I'm using SharePoint with the SPServices jQuery library, and I'm making use of the SPGetCurrentUser
function. However, it seems it just returns the login user name without the ID. Example:
DOMAIN\user
I need the whole account name with ID:
1;#DOMAIN\user
If there's a way just to return the ID I can concatenate the two together. But I can't find it.
Ultimately I'm trying to assign a list item to the current user. If there's a way to do this without the ID I'm open to that possibility as well. Thanks!
Ok I figured it out:
$().SPServices({
operation: "GetUserInfo",
async: false,
userLoginName: $().SPServices.SPGetCurrentUser(),
completefunc: function (xData, Status) {
$(xData.responseXML).find("User").each(function() {
curUserId = $(this).attr("ID");
curUserName = $(this).attr("Name");
curFullUserName = $(this).attr("ID")+";#"+$(this).attr("Name");
});
}
});
This little function will create three vars:
Hope it helps!
You can try:
$().SPServices.SPGetCurrentUser({
fieldName: "ID"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With