Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Ti2rrDT9HFPDJ+oiRJxe9B
Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Patch collection with pictures column to SharePoint List with image column

Like (0) ShareShare
ReportReport
Posted on 16 Mar 2025 10:30:16 by 18
Hello everyone,
 
I’ve been trying to figure out how to solve my problem without any success.
The goal is relatively simple: Copy images from my collection to Sharepoint list.
 
 
In my collection, the images are in a format without the "data:image/png;base64," prefix.
 
First step:
I created a custom collection containing all the necessary information, including the image column.
ClearCollect(
    colResultsUpdated,
        AddColumns(
            colResults,
                NameSession, varSessionName,
                Code, varProductCode,
                Product_Name, varProductName,
                Photos,
                {
                    Name: ThisRecord.Guid,  
                    Image: LookUp(colImage, Guid = ThisRecord.Guid, Img)
                }
 
    )
);
 
Second step:
Store data to sharepoint list
ForAll(colResultsUpdated,
    Patch('Liste - CP Label - Scan History',
        {
            SessionName: ThisRecord.NameSession,
            Index: Value(ThisRecord.Index),
            Code: ThisRecord.Code,
            ProductName: ThisRecord.Product_Name,
            Bypassed: ThisRecord.Bypassed,
            Company_OK: ThisRecord.Company_OK,
            Supplier_OK: ThisRecord.Supplier_OK,
            Photos:
                {
                    Name: ThisRecord.Photos.Name,
                    Image: JSON(ThisRecord.Photos.Image, JSONFormat.IncludeBinaryData),
                    Full: ThisRecord.Photos.Image,
                    Large: ThisRecord.Photos.Image,
                    Medium: ThisRecord.Photos.Image,
                    Small: ThisRecord.Photos.Image
                   
                }
 
        }
    )
)
 
This code works without any issues, but the images are not being copied as expected (the column remains blank).
I’ve tried many different approaches without success.

Maybe you’ve already done this kind of operation? It’s my first time dealing with it.

Thanks a lot for your support!
Have a nice day
  • Suggested answer
    SwatiSTW Profile Picture
    417 Super User 2025 Season 1 on 16 Mar 2025 at 13:46:18
    Patch collection with pictures column to SharePoint List with image column
    Solution 1: Stores images in a SharePoint document library and saves the image URL in a SharePoint list for easy access and efficient storage.
    1. Create SharePoint Document Library (e.g., ImageLibrary).
    2. Modify Collection to Include Image Name:
        ClearCollect(
            colResultsUpdated,
            AddColumns(
                colResults,
                NameSession, varSessionName,
                Code, varProductCode,
                Product_Name, varProductName,
                Photos,
                {
                    Name: "Image_" & ThisRecord.Guid & ".jpg",
                    Image: LookUp(colImage, Guid = ThisRecord.Guid, Img)
                }
            )
        );
    3. Create Power Automate Flow:
        Trigger: PowerApps.
        Convert Base64 to binary.
        Create file in SharePoint document library.
        Return file URL to PowerApps.
    4. Call Power Automate from PowerApps:
        
        Set(
            varImageURL,
            UploadImageFlow.Run(
                JSON(ThisItem.Photos.Image, JSONFormat.IncludeBinaryData),
                ThisItem.Photos.Name
            )
        );
    5. Patch to SharePoint List:
        Patch(
            'Liste - CP Label - Scan History',
            Defaults('Liste - CP Label - Scan History'),
            {
                SessionName: ThisRecord.NameSession,
                Index: Value(ThisRecord.Index),
                Code: ThisRecord.Code,
                ProductName: ThisRecord.Product_Name,
                Photos: varImageURL
            }
        );
    Solution 2: Stores the Base64-encoded image directly in a SharePoint list using a multiline text column (plain text format).
    1. Ensure "Photos" Column is Multiline Text (Plain Text).
    2. Modify Collection
        ClearCollect(
            colResultsUpdated,
            AddColumns(
                colResults,
                NameSession, varSessionName,
                Code, varProductCode,
                Product_Name, varProductName,
                Photos, JSON(LookUp(colImage, Guid = ThisRecord.Guid, Img), JSONFormat.IncludeBinaryData)
            )
        );
    3. Patch Base64 String to SharePoint List:
        Patch(
            'Liste - CP Label - Scan History',
            Defaults('Liste - CP Label - Scan History'),
            {
                SessionName: ThisRecord.NameSession,
                Index: Value(ThisRecord.Index),
                Code: ThisRecord.Code,
                ProductName: ThisRecord.Product_Name,
                Photos: ThisRecord.Photos
            }
        );
    4. Display Image in PowerApps:
        Image Control Image Property:
        "data:image/png;base64," & ThisItem.Photos
        
    Solution 1 is recommended for efficient storage; Solution 2 works for small images. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,442 Most Valuable Professional

Leaderboard
Loading started
Loading complete