diff --git a/UserPeoplePicker.js b/UserPeoplePicker.js index d6bbf5b..be511c7 100644 --- a/UserPeoplePicker.js +++ b/UserPeoplePicker.js @@ -86,9 +86,13 @@ function GetPeoplePickerUserID(userNameString) { var itemID = ""; $.ajax({ - url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/ensureUser('" + encodeURIComponent(userNameString) + "')", + url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/ensureuser", method: "POST", async: false, + contentType: "application/json;odata=verbose", + data: JSON.stringify({ + logonName: userNameString + }), headers: { "Accept": "application/json; odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() diff --git a/UserPeoplePicker.min.js b/UserPeoplePicker.min.js index a90e7f7..f59dc04 100644 --- a/UserPeoplePicker.min.js +++ b/UserPeoplePicker.min.js @@ -1 +1 @@ -!function(e){function t(e){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src","/_layouts/15/"+e),document.getElementsByTagName("head")[0].appendChild(t)}function n(e){var t={};t.PrincipalAccountType="User,DL,SecGroup,SPGroup",t.SearchPrincipalSource=15,t.ResolvePrincipalSource=15,t.AllowMultipleValues=!0,t.MaximumEntitySuggestions=50,t.Width="280px",this.SPClientPeoplePicker_InitStandaloneControlWrapper(e,null,t)}function r(e){if(void 0!=e){var t=e+"_TopSpan",n=null,r=this.SPClientPeoplePicker.SPClientPeoplePickerDict;for(var i in r)if(i==t){n=r[i];break}return n}}function i(e){var t=r(e);if(null!=t){for(var n=t.GetAllUserInfo(),i=[],o=0;o0)return a(e(this).attr("id"),t)}}(jQuery); +!function(e){function t(e){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src","/_layouts/15/"+e),document.getElementsByTagName("head")[0].appendChild(t)}function n(e){if(null!=e){var t=e+"_TopSpan",n=null,r=this.SPClientPeoplePicker.SPClientPeoplePickerDict;for(var i in r)if(i==t){n=r[i];break}return n}}function r(t,r){var i=n(t);null!=i&&r.forEach(function(t){var n=function(t){var n="";return e.ajax({url:_spPageContextInfo.webAbsoluteUrl+"/_api/web/getuserbyid("+t+")",method:"GET",async:!1,headers:{Accept:"application/json; odata=verbose"},success:function(e){n=e.d},error:function(e){console.log(e)}}),n}(t);null!=n&&i.AddUserKeys(n.LoginName,!1)})}function i(t){var n="";return e.ajax({url:_spPageContextInfo.webAbsoluteUrl+"/_api/web/ensureuser",method:"POST",async:!1,contentType:"application/json;odata=verbose",data:JSON.stringify({logonName:t}),headers:{Accept:"application/json; odata=verbose","X-RequestDigest":e("#__REQUESTDIGEST").val()},success:function(e){n=e.d.Id},error:function(e){console.log(e)}}),n}t("clienttemplates.js"),t("clientforms.js"),t("clientpeoplepicker.js"),t("autofill.js"),e.fn.spPeoplePicker=function(){var t=e(this).attr("id");ExecuteOrDelayUntilScriptLoaded(function(){!function(e){var t={PrincipalAccountType:"User,DL,SecGroup,SPGroup",SearchPrincipalSource:15,ResolvePrincipalSource:15,AllowMultipleValues:!0,MaximumEntitySuggestions:50,Width:"280px"};this.SPClientPeoplePicker_InitStandaloneControlWrapper(e,null,t)}(t)},"sp.core.js")},e.fn.GetUserNames=function(){return function(e){var t=n(e);if(null!=t){for(var r=t.GetAllUserInfo(),i="",o=0;o0)return r(e(this).attr("id"),t)}}(jQuery);