3

How can I get Value from Person or Group Type Field from a List form. Context here is a SharePoint list. the point is I need to do this for validation purpose. So I need the value entered in this field by the user. I have tried using SPutility but it's not working.

Any other way possible?

3
  • Is the REST-API an option?
    – Patrick
    Sep 2, 2016 at 12:30
  • Yes why not. But the point is I need to do this for validation purpose. So I need the value entered in this field by the user (Not the values from the list items).
    – mohd tahir
    Sep 2, 2016 at 12:32
  • I think JQuery's the easiest approach for validation. What is your rule?
    – Erin L
    Sep 2, 2016 at 15:02

2 Answers 2

1

I found a work-around for this. Though this can't be done with sputility. This is how we can pick value from Person or group/ People picker field :

http://howtolearnsharepoint.blogspot.in/2015/12/get-and-set-sharepoint-2013-people.html

This might help someone else.

0
function getItems(url) {
$.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + url,
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
    },
    success: function (data) {            
    //gets your data in console
    console.log(data.d.results);
    },
    error: function (error) {
        alert(JSON.stringify(error));
    }
});
}

var urlForAllItems = "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=ID,SpPerson/Title,SpPerson/Id&$expand=SpPerson";
getItems(urlForAllItems);
3
  • This doesn't solves my problem. Not the expected answer sorry. I need the value entered by the user currently for this purpose. That too from people picker filed.
    – mohd tahir
    Sep 9, 2016 at 5:41
  • can you elaborate what validation you want.
    – Sunil Sahu
    Sep 9, 2016 at 8:14
  • Please read my question and the answer which I have given again. In brief I just wanted to pick the value entered by user in the Newform.aspx for a list.(Field's data type is Person/Group).
    – mohd tahir
    Sep 9, 2016 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.