Monday 25 June 2012

Get Login Id from a People Picker field using JQuery SharePoint 2010


While I was trying to get current user's Login id in our SharePoint Online site I figured out an interesting example where you can get user's login id domain\id from a People Picker or Person and Group filed with JQuery.

<script src="/lib/jquery-latest.js" type="text/javascript"></script>

<script typpe="text/javascript">
$(document).ready(function(){
var personfield= $("#PP_ID");
var text=personfield.find('span').attr('Title');
alert(text);
});
</script>

Note: Please replace
#PP_ID is with somthing like "#ctl00_m_g_dc9b4708_9dc5_42ea_a42d_646acedbb088_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_UserField_upLevelDiv" which will be the ID of your people picker control on the page.

Ads by Google

1 comment: