Get image from Attachment and populate image field in sharepoint lists

Hi there i know i can use HTTP request to get an url from an attachment and populate sharepoint lists with a picture (students picture)

But i´m struggling with the solution.
Is there a way around ? Could anyone help me on this?

Thank you very much

Hello @eikmeier,

Welcome to Plumsail Community!

Where the images are stored? In a SharePoint list as item attachments?

Do you need to display the picture on the form or attach the file to the new item?

Hi thank you very much. I need to display the picture inside the list. Not as an attachment.

Here is the scenario: this is an application form for a School. So students will attach their CV´s Documents and a photo as applicants. Teachers should than see their photos in galery view on lists. I already figured out that this is possible using HTTP request. But i was not able to put it through.

Thanks for your reply ! :slight_smile:

@eikmeier,

You can get the image URL attached to the item by making PnP request. Then display the image in the Image field.

Update the list name and field internal names in the code:

var name = fd.field('Title').value;

pnp.sp.web.lists.getByTitle("ListName").items.filter("Title eq '" + name + "'").get().then(function(items) {
    return items[0]
}).then(function(item) {
    pnp.sp.web.lists.getByTitle("ListName").items.getById(item.Id).attachmentFiles.select("ServerRelativeUrl")().then(function(file) {
        if (file.length > 0) {
            return file[0].ServerRelativeUrl
        }
    }).then(function(url) {
        fd.field('ImageField').value.serverRelativeUrl = url
    })
})

So, just to be clear.
1 - I cerate a column in Microsoft Lists to receive attachments from power automate.

2 - In power automate I populate this column with the attachments from Plumsail using the instructions in your documentation.

3 - Than in my image Column i use this code in "format column" to get the URL from the column i used to populate with the image url.

Is that right?

@eikmeier,

I'm sorry, I don't seem to understand your requirements.

Are you using public forms to collect data from students? Do you need to save this data to SharePoint?

If so, the attached files can be saved to the SharePoint document library. And you can associate these files with a SharePoint list item and display them in the list view using the Hyperlink column. This all can be done in Power Automate, no code on the form is required.

Hi again @mnikitina,
I need to do this same process in SharePoint 2019 on-premise: display a photo which is in a different library. Is this possible? I don't see an "Image" field type under SharePoint fields in my list. I can see the field that I am trying to store the photo in, and I can enter the URL in the field name, but the photo doesn't display on the form itself.

Thanks, Rhonda

You need to use Hyperlink or Picture field and choose to display the URL as a picture: