0

I am trying below code but unable to read name from Custodian column value which is people picker, it always show me id

     jquery.ajax({
                url: `${reactHandler.props.siteurl}/`+_options[i].key+`/_api/web/Lists/GetByTitle('Documents')/GetItems(query=@v1)?@v1={'ViewXml':'<View><ViewFields><FieldRef Name=\"Title\"/><FieldRef Name=\"Date\"/><FieldRef Name=\"Business\"/><FieldRef Name=\"Number\"/><FieldRef Name=\"Business\"/><FieldRef Name=\"Custodian\"/></ViewFields><Query><Where><And><Neq><FieldRef Name=\"_IsRecord\"/><Value Type=\"Computed\">0</Value></Neq><IsNotNull><FieldRef Name=\"_IsRecord\" /></IsNotNull></And></Where></Query></View>'}`,
        
                type: "POST",
            
                headers: {
                    "Accept": "application/json;odata=verbose",
                    "Content-Type": "application/json;odata=verbose",  
                    "X-RequestDigest": data.d.GetContextWebInformation.FormDigestValue,
                    "X-HTTP-Method": "POST"
        
        
                    //"X-RequestDigest": jquery("#__REQUESTDIGEST").val()
                },
            
            
            success: function(data) {
              
              if (data.d.results.length > 0) { 
              
            for (var i = 0; i < data.d.results.length; i++) {
                            var odata = data.d.results[i];
                            _items.push({
                              key: odata.ID,
                              name: odata.Number ,
                              value: odata.ID,
                              iconName: odata.ID,
                              fileType: odata.ID,
                              modifiedBy: odata.Title,
                              dateModified: odata.Date.split('T')[0],
                              dateModifiedValue: odata.Business.Label,
                              fileSize: odata.Business.Label,
                              fileSizeRaw: odata.Business.Label,
                              Custodian:odata.Custodian
                              });
        
                            //console.log(items);
                            
                            }
1

You could use $expand in rest api to get user name.

/_api/web/lists/getbytitle('test')/items?$select=people/Id,people/Name&$expand=people

Similar issue:

https://social.technet.microsoft.com/Forums/Exchange/en-US/677bfd8b-14cc-477b-9bfa-c8488d2f3219/expand-user-field-in-rest-caml?forum=sharepointgeneral

Updated: enter image description here

My test caml for your reference:

`<View>  
            <Query> 
               <Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>27</Value></Eq></Where> 
            </Query> 
             <ViewFields><FieldRef Name='people' /><FieldRef Name='managed' /></ViewFields> 
      </View>
7
  • i am using caml to extract label from managed metadata column , if i do rest call managed metadata column is showing ID – kumar Aug 17 '20 at 3:33
  • As I test, I can get the manged metadata label. – Amos_MSFT Aug 18 '20 at 3:17
  • my managed metadata column is single value selection in rest call its coming as ID , in camll i am able to get as Label but unable to expand People picker in caml query – kumar Aug 18 '20 at 11:20
  • i want to expand people picker in caml is this possible ? – kumar Aug 18 '20 at 11:21
  • I do not find a way to expand people column in rest caml. – Amos_MSFT Aug 19 '20 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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