locked
How to get people picker value using JS Link feature RRS feed

  • Question

  • Hi All,

    We are using JS Link new feature of SharePoint 2013. I have a people picker column in my list. I want to get that column value for an item. When am using

    function () {
       //
     var itemCtx = {};
     itemCtx.Templates = {};
     itemCtx.Templates.Header = "<ul class='rslides'  id='Annsslider'>";
     itemCtx.Templates.Footer = "</ul>";
     itemCtx.Templates.Item = ItemOverrideFun;
     itemCtx.BaseViewID = 1;
     itemCtx.ListTemplateType = 104;
     
     SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);

    })();

    function ItemOverrideFun(ctx) {
     
    var _announcementTitle = ctx.CurrentItem.Title;
    var _announcementDesc = ctx.CurrentItem.Body;
    var _announcementID = ctx.CurrentItem.ID;
    var _announcemtImage=ctx.CurrentItem.Image;

    var _announcementsUser=ctx.CurrentItem.User;

    }

    Am getting error at line:

    var _announcementsUser=ctx.CurrentItem.User;

    where user is my people picker column name.

    Please help me with your inputs.

    Thanks


    Rajani.J


    Rajani.J

    Thursday, July 18, 2013 12:46 PM

Answers

  • Hi All,

    At last I was able to resolve this. Here is the code for the same.

    var _announcemtUser=ctx.CurrentItem.User[0].title;

    Thanks.


    Rajani.J

    • Marked as answer by Rajani Jilla Wednesday, July 24, 2013 9:41 AM
    Wednesday, July 24, 2013 9:41 AM

All replies

  • please help its very urgent for my project.

    Rajani.J

    Friday, July 19, 2013 12:49 AM
  • Hi,

    Please share your inputs. Is any limitation for the people picker?

    Thanks.


    Rajani.J

    Tuesday, July 23, 2013 9:24 AM
  • Hi All,

    At last I was able to resolve this. Here is the code for the same.

    var _announcemtUser=ctx.CurrentItem.User[0].title;

    Thanks.


    Rajani.J

    • Marked as answer by Rajani Jilla Wednesday, July 24, 2013 9:41 AM
    Wednesday, July 24, 2013 9:41 AM
  • Hi All,

    var UserName = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    var accMyName = "";
        if (UserName.length > 0)
        {
            accMyName = UserName[0].title;      
        }

    Friday, January 9, 2015 1:38 PM