{"id":41,"date":"2022-02-03T19:40:14","date_gmt":"2022-02-03T16:40:14","guid":{"rendered":"http:\/\/foonk.ddns.net\/?p=41"},"modified":"2022-10-19T10:11:44","modified_gmt":"2022-10-19T07:11:44","slug":"peoplepicker-%d0%b2%d1%81%d0%b5-%d1%87%d1%82%d0%be-%d0%bd%d1%83%d0%b6%d0%bd%d0%be-%d0%b4%d0%bb%d1%8f-%d1%80%d0%b0%d0%b1%d0%be%d1%82%d1%8b-%d1%81-%d0%ba%d0%bb%d0%b8%d0%b5%d0%bd%d1%82%d1%81%d0%ba","status":"publish","type":"post","link":"https:\/\/kb.astrocroc.com\/?p=41","title":{"rendered":"PeoplePicker &#8212; \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435-\u0440\u0435\u0448\u0435\u043d\u0438\u0435\">\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n\n\n\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 User field \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">\/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u043f\u043e\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0439 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440)\nfunction GetPeoplePickerUsersData(divID)\n{\n\tvar result = {};\n\n\tvar $ppDIV = $(&quot;div[id=&#039;&quot;+ divID +&quot;&#039;]&quot;);\n\tvar $ppEntities = $ppDIV.find(&quot;#divEntityData&quot;);\n\t\n\t$ppEntities.each(function() \n\t{\n\t\t\/\/\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0438\u043c\u044f\n\t\tvar displayName = $(this).attr(&quot;displaytext&quot;);\n\t\tresult[&quot;DisplayName&quot;] = displayName;\n\t\t\/\/\u041d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435\n\t\tvar isResolved = $(this).attr(&quot;isresolved&quot;);\n\t\tresult[&quot;Resolved&quot;] = isResolved;\n\t\t\n\t\t\/\/\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c XML \u0441 \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438\n\t\tvar entityXML = $(this).find(&quot;div&quot;).attr(&quot;data&quot;);\n\t\tvar xmlDoc = $.parseXML(entityXML);\n\t\t$(xmlDoc).find(&quot;DictionaryEntry&quot;).each(function () {\n\t\t\tvar key = $(this).find(&quot;Key&quot;).text();\n\t\t\tvar value = $(this).find(&quot;Value&quot;).text();\n\t\t\tresult[key] = value;\n\t\t})\n\t});\n\treturn result;\n}<\/code><\/pre>\n\n\n\n<p>\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">\/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f\nvar mngData = GetPeoplePickerUsersData(&quot;ctl00_ctl50_g_e4ccc992_8553_4a5e_8700_60e9eba33a9b_ff921_ctl00_ctl00_UserField_upLevelDiv&quot;);\nconsole.log(mngData.DisplayName);\n\nDisplayName: &quot;\u041a\u043e\u0440\u0433\u0443\u043b\u044c \u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0411.&quot;\nResolved: &quot;True&quot;\nPrincipalType: &quot;User&quot;\nTitle: &quot;\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0444\u0438\u043b\u0438\u0430\u043b\u0430&quot;\nEmail: &quot;t.korgul@ural.pac.ru&quot;\nSPUserID: &quot;107&quot;\nAccountName: &quot;i:0#.w|pac\\ekb1&quot;\nSIPAddress: &quot;smtp:mrk@chel.pac.ru&quot;\nDepartment: &quot;\u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433\u0441\u043a\u0438\u0439 \u0444\u0438\u043b\u0438\u0430\u043b&quot;<\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 DispForm (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440)<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">var sField2 = $(&#039;.ms-standardheader:contains(&quot;\u0423\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438&quot;)&#039;).parent(&#039;td&#039;).next(&#039;td&#039;).find(&#039;.ms-peopleux-userdisplink&#039;).text();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435-\u0440\u0435\u0448\u0435\u043d\u0438\u0435\">\u041d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n\n\n\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"\" data-line=\"\">&lt;!-- \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PeoplePicker --&gt;\n&lt;script src=&quot;..\/_layouts\/15\/clientpeoplepicker.js&quot;&gt;&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u043e\u043b\u0435 (\u0447\u0442\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f)<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">\/\/Set PeoplePicker users (\u0447\u0442\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f)\nfunction SetAndResolvePeoplePicker(fieldName, userAccountName) {\n\tvar controlName = fieldName;\n\tvar peoplePickerDiv = $(&quot;[id$=&#039;ClientPeoplePicker&#039;][title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n\tvar peoplePickerEditor = peoplePickerDiv.find(&quot;[title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n\tvar spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];\n\t\n    peoplePickerEditor.val(userAccountName);\n\tspPeoplePicker.AddUnresolvedUserFromEditor(true);\n\n    \/\/ \u0418\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 2 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 \n    \/\/spPeoplePicker.AddUserKeys(userAccountName);\n} \n\n\/\/\u0412\u044b\u0437\u043e\u0432\nSetAndResolvePeoplePicker(&quot;\u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f&quot;, val);<\/code><\/pre>\n\n\n\n<p>\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u0435<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">\/\/Clear People Picker\nfunction ClearPeoplePicker(fieldName)  {\n\tvar controlName = fieldName;\n\tvar peoplePickerDiv = $(&quot;[id$=&#039;ClientPeoplePicker&#039;][title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n\tvar peoplePickerEditor = peoplePickerDiv.find(&quot;[title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n\tvar spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];\n\tvar usersobject = spPeoplePicker.GetAllUserInfo();\n\tusersobject.forEach(function (index) {\n\t  \tspPeoplePicker.DeleteProcessedUser(usersobject[index]);\n\t});\t\t\t\n} <\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0438\u0437 \u043f\u043e\u043b\u044f PeoplePicker<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">\/\/\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0438\u0437 \u043f\u043e\u043b\u044f PeoplePicker\nfunction getInfoFromPeoplePicker(title) \n{\n\tvar controlName = title;\n    var peoplePickerDiv = $(&quot;[id$=&#039;ClientPeoplePicker&#039;][title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n    var peoplePickerEditor = peoplePickerDiv.find(&quot;[title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n    var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];\t\t \n    var userList = spPeoplePicker.GetAllUserInfo();\n    var userInfo = userList[0];\n    \/\/The description field contains the login info without the lookup extras.  In new forms this \n    \/\/field can be undefined depending on the field being checked.  Only check if userInfo is\n    \/\/initialized.\n    if(userInfo != null)\n    {\n        userEmail = userInfo.EntityData.Email;\n    }\t\t \n    return userInfo; \n}<\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 EditForm<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">\/\/\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 EditForm\nfunction getUsersFromPeoplePicker(title) {\n    var controlName = title;\n    var peoplePickerDiv = $(&quot;[id$=&#039;ClientPeoplePicker&#039;][title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n    var peoplePickerEditor = peoplePickerDiv.find(&quot;[title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n    var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];\t\t \n    var userList = spPeoplePicker.GetAllUserInfo();\n    \n    var userNames = &quot;&quot;;\n   \t$(userList).each(function(i) {\n\t\t\tconsole.log(userList[i].DisplayText);\n\t\tuserNames += userList[i].DisplayText;\n\t});\n\n    return userNames;\n}<\/code><\/pre>\n\n\n\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 PeoplePicker<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\" data-line=\"\">\/\/\u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 PeoplePicker\nfunction disablePeoplePicker(title) {\n    var controlName = title;\n    var peoplePickerDiv = $(&quot;[id$=&#039;ClientPeoplePicker&#039;][title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n    var peoplePickerEditor = peoplePickerDiv.find(&quot;[title=&#039;&quot; + controlName + &quot;&#039;]&quot;);\n    var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];\t\t \n    spPeoplePicker.SetEnabledState(false);\n    $(peoplePickerDiv).find(&#039;.sp-peoplepicker-delImage&#039;).hide();\n}\n\ndisablePeoplePicker(&quot;\u0423\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438&quot;);<\/code><\/pre>\n\n\n\n<p>\u0415\u0441\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f sp.js \u0442\u043e\u0433\u0434\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"\" data-line=\"\">$(document).ready(function() \n{\t\n\tExecuteOrDelayUntilScriptLoaded(CustomAction, &quot;sp.js&quot;);\t\n\n\tfunction CustomAction()\n    {\n       \/\/Your Code\n    }\n});\t<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 User field \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 DispForm (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440) \u041d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u043e\u043b\u0435 (\u0447\u0442\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f) \u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0438\u0437 \u043f\u043e\u043b\u044f PeoplePicker \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 EditForm [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[39,33],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-peoplepicker","tag-sharepoint"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":2,"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":183,"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions\/183"}],"wp:attachment":[{"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.astrocroc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}