How to get SharePoint list field value of type person or group using ecmascript or SPServices?

Following is my code…

function retrieveListItems() {
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('list name');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'ID\'/>' + < Value Type = \'Integer\'>413</Value></Eq></Where></Query></View>');
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args) {
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();
    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        listItemInfo += 'Title: ' + oListItem.get_item('Writer').get_lookupValue();
    }
    alert(listItemInfo.toString());
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

I even tried with oListItem.get_item('Writer').get_title() but it is not working..
Sometime it returns undefined…
Please help..

  • Can we delete ES6 class?
  • What's the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?
  • Webpack fails to build ES6 in external packages
  • Testing React: Target Container is not a DOM element
  • Typescript cannot find local es6 module; error TS2307: Cannot find module
  • Convert closure to es6 module
  • Douglas Crockford on Class Free OOP in JavaScript
  • What is the difference between Reactive-Extensions/RxJS and ReactiveX/rxjs
  • How to use Immutable JS with typed ES6 classes?
  • How to construct subclasses of Immutable.Record?
  • Angular.js DI with (ES6) classes and inheritance
  • ECMA6 - Use of Generator Function in JavaScript
  • One Solution collect form web for “How to get SharePoint list field value of type person or group using ecmascript or SPServices?”

    If you are looking for list item ‘Created By’ value then use ‘Author’ instead of ‘Writer’ or if you want ‘Modified By’ value then use ‘Editor’ instead of ‘Writer’.