0

I have created a Lookup field linked to the document library which allows multiple files.

I am able to get the Title of the linked documents, but I can't find a way to get the url? How can this be done?

This is my Expand and select query &$expand=LeftBox&$select=Title,ModelType,ModelOrder,ID,Description,LeftBox/Title

LeftBox is the lookup field to the document library.

  $.ajax({  
    async: false,  
    url: "https://MySharePointSite.sharepoint.com/sites/TransformationOffice/_api/web/lists/GetByTitle('ProjectModel')/items?$orderby=ModelOrder,ModelType&$expand=LeftBox&$select=Title,ModelType,ModelOrder,ID,Description,LeftBox/Title",  
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function(data) {
      data.d.results.forEach(item => { 
        console.log(item);

      });
    },  
    error: function(error) {  
        console.log(JSON.stringify(error));  

    }  
3

You will not be able to get the URL of lookup documents directly using only one REST Call.

You need to make the Nested REST calls in order to get the URL of lookup documents.

First, you need to get the ID of document from lookup as given below:

https://MySharePointSite.sharepoint.com/sites/TransformationOffice/_api/web/lists/GetByTitle('ProjectModel')/items(itemId)?$expand=LeftBox&$select=LeftBox/ID,LeftBox/Title

Then You need to fetch the URL of document from document library as follows(Using document ID you got from first REST call):

https://MySharePointSite.sharepoint.com/sites/TransformationOffice/_api/web/lists/GetByTitle('LibraryName')/items(documentId)?$select=FileRef

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.