[SharePoint 2013] Set value for people editor with JSOM

Source: Internet
Author: User

function Peoplepicker () {this.context = null;    This.web = null;    This.currentuser = null; This.parenttagid = null this.    Setparenttagid = function (id) {this.parenttagid = ID; } this.        Setloggedinuser = function () {if (This.parenttagid! = null) {this.getwebuserdata (); }} this.getwebuserdata = function () {this.context = new SP.        Clientcontext.get_current ();        This.web = This.context.get_web ();        This.currentuser = This.web.get_currentUser ();        This.currentUser.retrieve ();        This.context.load (This.web);                                       This.context.executeQueryAsync (Function.createdelegate (this, This.onsuccessmethod),    Function.createdelegate (this, this.onfailuremethod));    } This.onsuccessmethod = function () {This.setdefaultvalue (This.currentUser.get_title ()); } This.onfailuremethod = function () {alert (' request failed ' + args.get_message () + ' \ n ' + args.get_stackTrace ());        } This.setdefaultvalue = function (value) {var Parenttag = document.getElementById (This.parenttagid);            if (Parenttag! = null) {var _ppe = $ ("input[title= '" + $ (parenttagid). attr (' title ') + "']");            _ppe.val (value);            var _ppo = Spclientpeoplepicker.spclientpeoplepickerdict[this.parenttagid]; _ppo.        Addunresolveduserfromeditor (TRUE);    }}}function Setwebuserdata () {var pplpicker = new Peoplepicker (); var controlId = $ (' Td.ms-formlabel:contains (' field name ') '). Siblings (' TD '). FIND (' div[title= ' field name '] '). Prop ("ID    ");    Pplpicker.setparenttagid (CONTROLID); Pplpicker.setloggedinuser ();} $ (document). Ready (function () {executeordelayuntilscriptloaded (Setwebuserdata, "sp.js");});

  

[SharePoint 2013] Set value for people editor with JSOM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.