Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I traced how address book interacts with user field. To get values it uses function getUplevel(ctx) and to set values can be used function EntityEditorCallback(xml, ctx). First function will return html/xml mixed string with user information. Second function input must be special formatted xml string.</p> <pre><code>// Get values var ctx='ctl00_m_g_e5a1501a_..._ctl04_ctl00_ctl00_UserField'; var values=getUplevel(ctx); alert(values); // Set values var xml='&lt;Entities Append="False" Error="" Separator=";" MaxHeight="3"&gt;'+ '&lt;Entity Key="DOMAIN\\loginname" DisplayText="Display Name" IsResolved="True" Description="DOMAIN\\loginname"&gt;'+ '&lt;ExtraData&gt;'+ '&lt;ArrayOfDictionaryEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;'+ '&lt;DictionaryEntry&gt;&lt;Key xsi:type="xsd:string"&gt;DisplayName&lt;/Key&gt;&lt;Value xsi:type="xsd:string"&gt;Display Name&lt;/Value&gt;&lt;/DictionaryEntry&gt;'+ '&lt;DictionaryEntry&gt;&lt;Key xsi:type="xsd:string"&gt;Email&lt;/Key&gt;&lt;Value xsi:type="xsd:string"&gt;Display.Name@domain.ee&lt;/Value&gt;&lt;/DictionaryEntry&gt;'+ '&lt;DictionaryEntry&gt;&lt;Key xsi:type="xsd:string"&gt;SPUserID&lt;/Key&gt;&lt;Value xsi:type="xsd:string"&gt;1&lt;/Value&gt;&lt;/DictionaryEntry&gt;'+ '&lt;DictionaryEntry&gt;&lt;Key xsi:type="xsd:string"&gt;PrincipalType&lt;/Key&gt;&lt;Value xsi:type="xsd:string"&gt;User&lt;/Value&gt;&lt;/DictionaryEntry&gt;'+ '&lt;/ArrayOfDictionaryEntry&gt;'+ '&lt;/ExtraData&gt;'+ '&lt;MultipleMatches /&gt;'+ '&lt;/Entity&gt;'+ '&lt;/Entities&gt;'; EntityEditorCallback(xml,ctx); </code></pre> <p>Tricky part is ctx attribute that must be target field id. In user field html there is no title attribute, so to find right element by display name with js is very complex. I suggest to pass field id to the javascript from server side. For example you can create custom WebPart where you write to the page field id-s from collection SPContext.Current.FormContext.FieldControlCollection.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload