I have a page that needs to retrieve the department for the logged-in user. Ideally I'd like to be able to do it through a JavaScript SOAP CAML query. I have the user's id (which I'm assuming doubles as the GUID), so it seems like a simple matter of retrieving the row that matches the ID.
I'm looking into using the 'GetUserProfileByIndex' or 'GetUserProfileByGuid' function in SOAP, but I can't seem to find any solid documentation or decent examples using them. I'm hoping to do something like this in JavaScript - (which isn't working):
var userId = 194;
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetUserProfileByIndex xmlns='http://microsoft.com/webservices/SharePointPortalServer/UserProfileService'> \
<index>userId</index> \
</GetUserProfileByIndex > \
</soapenv:Body> \
</soapenv:Envelope>";
I recommend you check out the jQuery Library for SharePoint 2007 and 2010 called SPServices. $().SPServices.SPGetCurrentUser can retrieve the Department in an effecient 4 lines of code:
var thisDepartment = $().SPServices.SPGetCurrentUser({
fieldName: "Department",
debug: false
});