0

I have a sharepoint list that has an Employee Column (Person or Group) and an AwardType (Lookup). The AwardType is currently set to display a title from the document library.

Right now I have a CAML query that returns are the rows in that sharepoint list that are referring to a given user. What I need to do is get the award image files based on the lookup field.

e.g. If the user Roger, Williams has the catalyst award I will get back a row that has ows_AwardType="6;#Catalyst" and ows_Employee="472;Williams, Rogers". The AwardType is referring to a title in the document library and there is a jpeg file that was uploaded into the document library that I need a link/reference too so I can use it as the src for an tag.

Any thought?

  • you can't bring url of document via lookup.. you need some custom workflow or something to update a new field in your list..basically you need to query AwardType list again with select award type and get the url and update in your current list... – Siddharth Vaghasia Dec 9 '16 at 16:25
  • Really? Man sharepoint is such a pain. Why would you not be able to have a lookup field that refers to location of the resource. Well thanks. – MProgrammer Dec 9 '16 at 16:32
0

Yes...below are 2 options for you.

Option 1. Create a workflow to update your current list which will store image url based on Award type user has selected, you need to query Award type list based on id or Award name...

Option 2. Before binding src of tag, use below rest api url to get file

https://example.com/sites/dev/_api/Web/Lists/GetByTitle('Award Type')/Items(12)/File

In above example url - 12 stands for id of your item(award type) selected...

Below is sample response, Read ServerRelativeUrl property for getting url..

 {
        "__metadata": {
            "id": "https://fcatcs.sharepoint.com/sites/dev/_api/Web/GetFileByServerRelativeUrl('/sites/dev/Shared Documents/workbench.aspx')",
            "uri": "https://fcatcs.sharepoint.com/sites/dev/_api/Web/GetFileByServerRelativeUrl('/sites/dev/Shared%20Documents/workbench.aspx')",
            "type": "SP.File"
        },
        "Author": {
            "__deferred": {
                "uri": "https://example/sites/dev/_api/Web/GetFileByServerRelativeUrl('/sites/dev/Shared%20Documents/workbench.aspx')/Author"
            }
        },
"Level": 1,
    "LinkingUrl": "",
    "MajorVersion": 1,
    "MinorVersion": 0,
    "Name": "workbench.aspx",
    "ServerRelativeUrl": "/sites/dev/Shared Documents/workbench.aspx",
    "TimeCreated": "2016-09-08T08:55:02Z",
    "TimeLastModified": "2016-09-08T08:55:02Z",
    "Title": null,

    ....
    }

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.