直接放代码了,可以先用普通的rest工具查询看看结果再决定使用什么字段,我这里是读取上级经理
<script type="text/javascript" >
$(document).ready(function(){
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl+"/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=UserProfileProperties",
type: "GET",
headers: { "accept": "application/json;odata=verbose" },
success: function(data){
for(i=0; i<data.d.UserProfileProperties.results.length; i++){
if(data.d.UserProfileProperties.results[i].Key=="Department"){
$("#ctl00_ctl40_g_13f04e09_d97a_4c05_b16d_51e8765d9844_FormControl0_V1_I1_T2").val( data.d.UserProfileProperties.results[i].Value );
}
}
},
error: function(){ console.log('error'); }
});
});
</script>
这个代码适合Sharepoint 2013使用,对于sp 2010或office 365可能无法使用哦!