0

thank you for reading; my problem is:

I want to retrieve the values of the column "GroupWithPriority". That column is a Look Up from other list.

When I try to get the value, all I get is "GroupWithPriorityId" that gives only a number when I want to get the text... is it possible to do what I want?

I want to get "Group 1" but instead I get

I have already reached a lot and I found nothing :c

I would appreciate your response even if that means that there is no way to do what I want, thank you

My retrievement code looks something like this:

this.context.spHttpClient.get(requestUrl, SPHttpClient.configurations.v1)  
            .then((response: SPHttpClientResponse) => {  
                if (response.ok) {  
                    response.json().then((responseJSON) => {  
                        if (responseJSON!=null && responseJSON.value!=null){  
                            console.log(responseJSON.value);    
                        }  
                    }); 
                }  
            }); 

enter image description here

4
  • Please post your request Url (you may redact out your domain name) -- specifically looking at the syntax of your REST API call.
    – willman
    Mar 9, 2020 at 22:08
  • Hi Will, here is part of my request: "/_api/web/Lists/GetByTitle('myList')/items". 'myList' is the main list I'm using. 'Groups' is the second list from where the Look Up is taken Mar 9, 2020 at 22:46
  • If you can give me the name of your Lookup column, and name(s) of the column(s) you want to get to get from the Groups list, I can update my example in my answer below for your specific scenario.
    – willman
    Mar 9, 2020 at 23:09
  • Ah, nevermind, just saw your comment below. :)
    – willman
    Mar 9, 2020 at 23:10

1 Answer 1

1

In order to access values from the lookup column from a REST query, you need to add the $expand parameter to your REST URI to specify the name of the column to expand, then reference the fields in your $select prefixed with the Lookup columns name, the / character and the name of the field from the reference lookup item you wish to select. For example:

/_api/web/lists(guid'<guid>')/items?$select=Title,ID,LookupField/FieldInTargetList&$expand=LookupField
1
  • 1
    This is what I came with: ""/_api/web/Lists/GetByTitle('myList')/items/?$select=Title, Image, Link, Description, Group, GroupWithPriority/Title&$expand=GroupWithPriority"' Thank you very very much! It worked :))) Mar 9, 2020 at 23:00

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.