Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierFlux principal

Add, update, or delete images in SharePoint/Microsoft Lists using Power Apps

In my previous blog about image columns in SharePoint, I explained all you need to know about New Image column type in SharePoint online including how to create an image column, how to add image to a list item, where the Images will be stored, etc.

Last year Microsoft added support for displaying images from SharePoint Online/Microsoft Lists to Power Apps canvas apps. Now, Microsoft is adding support for adding, updating, and deleting images from image columns in SharePoint online/Microsoft Lists using Power Apps canvas apps.

Newly created canvas apps that have a SharePoint data connection and are connected to a list can use controls that can add, update, or delete images from the SharePoint list. To use the same functionality in existing canvas apps, you have to delete the existing SharePoint data connection and then re-add it to refresh the data schema.

Configure SharePoint Form control to add pictures/images

Follow below steps to configure SharePoint Form control in canvas app to add pictures/images to SharePoint lists:

1. Create a SharePoint online list and then create an image column in the SharePoint list.

2. Go to make.powerapps.com, create a blank canvas app and add SharePoint list data source.

3. Add Form control in app from Insert > Forms > Edit form

4. Set Data Source property of form control to SharePoint list data source and DefaultMode property to FormMode.New

5. Select form control from tree view, click on Edit fields option from Properties panel at the right side of screen.

6. Add your image column to form using + Add field option on Fields panel and select Add picture as a Control type as shown in below image. Power Apps will add Add picture control inside the data card for image column.

Add image column to form and select “Add picture” as control type

7. Add a button control in canvas app and set it’s OnSelect property to:

SubmitForm(Form1)

8. Now when you run the canvas application, you can select an image from your computer using Add picture control and save it to SharePoint list using SubmitForm() function used in button control.

Add, update, or delete images in SharePoint/Microsoft Lists using Power Apps

Using Patch() function to add/update image column using Power Apps

You can also use the Patch() function to add or update an image in image columns in SharePoint/Microsoft Lists using Power apps canvas apps. You can use similar code as given below on OnSelect property of button control:

Patch(
    'Logo Universe',
    Defaults('Logo Universe'),
    {
        Title: TextInputControl.Text,
        Image: ImageControl.Image
    }
)

Delete an image from SharePoint image column using Power Apps

You can delete an image from SharePoint image column using Blank() value for image column in Power Apps Patch function:

Patch(
    'Logo Universe',
    Defaults('Logo Universe'),
    {
        Title: TextInputControl.Text,
        Image: Blank()
    }
)

Limitations

  1. Images up to 30MB in size are supported while adding/updating images.
  2. Below image formats are supported currently while using this feature.

Supported Image formats

Below image formats are supported currently while using this feature:

  • JPG and JPEG
  • PNG
  • GIF
  • TIF and TIFF
  • HEIC and HEIF
  • JPE, MEF, MRW, NEF, NRW, ORF, PANO, PEF, RW2, SPM, XBM, XCF

Release Timeline

  • Targeted Release: Rollout started in late September 2022 (previously early September 2022) and expected to complete by mid-October 2022 (previously mid-September 2022).
  • Standard Release: Microsoft will begin rolling out this feature in mid-October 2022 (previously mid-September 2022) and expects to complete it by late October 2022 (previously late September 2022).

Learn more

I hope you liked this blog. Please give your valuable feedback & suggestions in the comments section below and share this blog with others.

Power Apps can now display images from SharePoint Online/Microsoft Lists

In my previous blog all you need to know about Image column type in SharePoint online, I explained how to create an image column, adding images to SharePoint list items and where the Images will be stored in SharePoint online site.

At the time I wrote that blog, it was not possible to display the images from SharePoint online/Microsoft lists in Power Apps. But, Power Apps image controls can now display images that are stored in image columns in SharePoint online/Microsoft Lists. The Images in Power Apps can be displayed in four different sizes:

  • Small
  • Medium
  • Large
  • Full

This feature is associated with Microsoft 365 Roadmap ID 81986.

How this will affect your organization

New Power apps that use the SharePoint connector to add a list as a data source may display images from the list if they are present in the list. Existing apps can also be updated to show images.

Release Timeline

  • Targeted release will begin rolling out in late February (previously early February) and will be complete by early March (previously end of February).
  • Standard release to all other cloud environments will begin early March (previously early February) and be complete by mid-March (previously mid-February).

What you need to do to prepare

You might want to notify your users about this new functionality and update your training and documentation as appropriate.

Learn more

SharePoint Online: All you need to know about New Image column type

Microsoft introduced a new Image column type to SharePoint Online lists and libraries. Using this column, list and library users will be able to add a single image file from their computer to an item in a list or a library.

History & Roadmap

  • Microsoft announced Image column first time via admin message center on July 31, 2020 (Message Center ID: MC219652).
  • When it was added to Microsoft 365 roadmap, it was expected to complete the rollout of image column to all by mid-August 2020.
  • On August 19, 2020, Microsoft delayed the rollout of this feature & updated the announcement stating, “To ensure the best possible experience for our users, we are delaying some of our deployments to reduce the amount of change flowing into the services.”
  • Finally, Image column feature released to all SharePoint Online tenants in October 2020 release, Roadmap.

Creating an Image Column

Follow below steps to create an image column in a SharePoint Online list:

  1. Go to SharePoint Online list where you want to create an image column.
  2. Click on Add column in list view and select Image. If you are not able to see the Image column option, then click on More…
  3. Name your column and make sure type is selected as Image.
  4. You can specify additional column settings as per your requirements and then click OK
Creating an Image column in SharePoint Online list
Creating an Image Column

When you create an Image column, it will be shown as a Thumbnail column in Columns section under list settings:

Columns in List settings in SharePoint Online
Columns section under list settings

Adding Image to list items

When you create a new item in list, Image column will be shown like below on list form. When you click on Add an image, you will be able to add a single image file from your computer to an item.

New Image column on list form in SharePoint Online
List form with image column

After you select an image from computer, the file name will be shown in the form. If you want to replace the image, you can click on Edit icon.

Image column on New item list form in SharePoint Online
List form after image is selected

Display in list view

Once you Save the list form, Image column will show the thumbnail of selected image in list view. If you want to see the image in full size, you need to click on image thumbnail in list view.

New Image column in SharePoint Online list view in modern experience
Images in list view

Where the Images will be stored?

After adding images to your SharePoint list items, you must be wondering about where these images will be stored in your SharePoint Online site.

Image columns in SharePoint online stores the images by default in a sub folder inside Site Assets library which has format in general like Site Assets –> Lists –> <GUID of list>

Images from Image columns stored in SharePoint Online Site Assets library
Images stored in Site Assets library

Update: With the recent updates to SharePoint Online and Microsoft Lists, if the attachments option is enabled in your list, images will be stored in same SharePoint list and general format for image location will be like below as mentioned in the article, Download Image from SharePoint Image column using JSON formatting:

https://contoso.sharepoint.com/sites/MySite/Lists/MyList/Attachments/[ID]/[ImageFileName]

I hope you liked this blog. Give your valuable feedback & suggestions in the comments section below and share this blog with others.

See also

Add/Update image columns in SharePoint lists using CLI for Microsoft 365

In my previous blog about image columns in SharePoint, I explained how to add or update image columns in SharePoint online lists or Microsoft Lists using PnP PowerShell and Power Automate.

In this blog, I will explain how to create a new list item with image column and update existing list item to update the image column using CLI for Microsoft 365.

Create new list item with Image column

You can use below CLI for Microsoft 365 script to create a new item in SharePoint online list with Image column:

# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your site URL (e.g https://<tenant>.sharepoint.com/sites/contoso)"

# Server Relative URL of image file from same SharePoint site
$serverRelativeUrl = Read-Host -Prompt "Enter Server Relative URL of image file (e.g /sites/contoso/SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/CLI-For-Microsoft-365-Blue.png)"

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# Get UniqueId of file you're referencing (without this part your image won't appear in Power Apps (browser or mobile app) or Microsoft Lists (iOS app))
$imageFileUniqueId = (m365 spo file get --webUrl $siteUrl --url $serverRelativeUrl | ConvertFrom-Json).UniqueId

# Create new list item with image column
m365 spo listitem add --listTitle "Logo Universe" --webUrl $siteUrl --Title "CLI for Microsoft 365" --Image "{'type':'thumbnail','fileName':'CLI-For-Microsoft-365-Blue.png','fieldName':'Image','serverUrl':'https://contoso.sharepoint.com','serverRelativeUrl':'$($serverRelativeUrl)', 'id':'$($imageFileUniqueId)'}"

# Disconnect SharePoint online connection
m365 logout
Create a new SharePoint list item with Image column in SharePoint online using CLI for Microsoft 365
Create new list item with Image column

Update SharePoint list item with Image column

You can use below CLI for Microsoft 365 script to update existing SharePoint list item with Image column:

# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your site URL (e.g https://<tenant>.sharepoint.com/sites/contoso)"

# Server Relative URL of image file from same SharePoint site
$serverRelativeUrl = Read-Host -Prompt "Enter Server Relative URL of image file (e.g /sites/contoso/SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/CLI-For-Microsoft-365-Blue.png)"

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# Get UniqueId of file you're referencing (without this part your image won't appear in Power Apps (browser or mobile app) or Microsoft Lists (iOS app))
$imageFileUniqueId = (m365 spo file get --webUrl $siteUrl --url $serverRelativeUrl | ConvertFrom-Json).UniqueId

# Update list item with image column
m365 spo listitem set --listTitle "Logo Universe" --id 15 --webUrl $siteUrl --Image "{'type':'thumbnail','fileName':'CLI-For-Microsoft-365-Blue.png','fieldName':'Image','serverUrl':'https://contoso.sharepoint.com','serverRelativeUrl':'$($serverRelativeUrl)', 'id':'$($imageFileUniqueId)'}"

# Disconnect SharePoint online connection
m365 logout
Update SharePoint list item with Image column in SharePoint online using CLI for Microsoft 365
Update SharePoint list item with Image column

Learn more

Download Image from SharePoint Image column using JSON formatting

In my previous blog about image columns in SharePoint, I explained all you need to know about New Image column type in SharePoint online including how to create an image column, how to add image to a list item, where the Images will be stored, etc.

You can add one image per SharePoint list item using SharePoint image column and the images are stored in Site Assets library by default. Using SharePoint online out of the box capabilities, there is no way to download the images from SharePoint list image column. In this blog, I will demonstrate how to create add a button within a SharePoint Online/Microsoft Lists modern experience view which downloads the image from SharePoint image column.

You can use below JSON to add a button in SharePoint online list column to download the image from image column in same list. This JSON formatting can be applied to any existing column in your SharePoint online list OR if you want to create a new column and then apply JSON formatting, follow the steps given in this blog: Working with SharePoint Online/Microsoft List Comments using JSON Formatting 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"style": {
"border-radius": "5px",
"margin": "5px 0px",
"padding": "0px",
"border": "none",
"display": "=if([$Image.serverRelativeUrl]=='','none','')"
},
"attributes": {
"class": "ms-bgColor-themePrimary"
},
"children": [
{
"elmType": "a",
"style": {
"text-decoration": "none",
"padding": "12px 0px",
"width": "100%"
},
"attributes": {
"href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+if([$Image.serverRelativeUrl],[$Image.serverRelativeUrl],@currentWeb+'/Lists/**YOUR-LIST-NAME**/Attachments/'+[$ID]+'/'+[$Image.fileName])",
"target": "_blank",
"class": "ms-fontColor-white ms-fontSize-m"
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
},
"attributes": {
"iconName": "Download"
}
},
{
"elmType": "span",
"txtContent": "Download"
}
]
}
]
}

Where [$Image] is the internal name of your SharePoint image column. Also, make sure to edit the above JSON and replace the **YOUR-LIST-NAME** placeholder with your list’s name, as it appears in the list URL (including special characters).

This SharePoint JSON formatting code adds a button within a SharePoint Online/Microsoft Lists modern experience view which downloads the image from SharePoint image column:

Download Image from SharePoint Online Modern experience Image column using JSON formatting
Download Image from SharePoint Image column using JSON formatting

Above JSON is also available on GitHub in PnP List Formatting Repository at: Download Image from SharePoint Image column.

Learn More

Add/Update image columns in SharePoint/Microsoft Lists using PnP PowerShell

In my previous blog about image columns in SharePoint, I explained all you need to know about New Image column type in SharePoint online including how to create an image column, how to add image to a list item, where the Images will be stored, etc.

In this blog, I will explain how to create a new list item with image column and update existing list item to update the image column using PnP PowerShell.

Create new list item with Image column

You can use Add-PnPListItem command in PnP PowerShell to create a new item in SharePoint list with Image column:

# Connect to SharePoint online site
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/spconnect -Interactive

# Get UniqueId of file you're referencing (without this part your image won't appear in Power Apps (browser or mobile app) or Microsoft Lists (iOS app))
$imageFileUniqueId = (Get-PnPFile -Url "SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Blue.png" -AsListItem)["UniqueId"]

# Create new list item with image column
Add-PnPListItem -List "Logo Universe" -Values @{"Title" = "PnP PowerShell"; "Image" = "{'type':'thumbnail','fileName':'PnP-PowerShell-Blue.png','fieldName':'Image','serverUrl':'https://contoso.sharepoint.com','serverRelativeUrl':'/sites/SPConnect/SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Blue.png', 'id':'$($imageFileUniqueId)'}"}
Create a new SharePoint list item with Image column in SharePoint online using PnP PowerShell
Create new list item with Image column

Update SharePoint list item with Image column

You can use Set-PnPListItem cmdlet in PnP PowerShell to update existing SharePoint list item with Image column:

# Connect to SharePoint online site
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/spconnect -Interactive

# Get UniqueId of file you're referencing (without this part your image won't appear in Power Apps (browser or mobile app) or Microsoft Lists (iOS app))
$imageFileUniqueId = (Get-PnPFile -Url "SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Green.png" -AsListItem)["UniqueId"]

# Update SharePoint list item with image column
Set-PnPListItem -List "Logo Universe" -Identity 12 -Values @{"Image" = "{'type':'thumbnail','fileName':'PnP-PowerShell-Blue.png','fieldName':'Image','serverUrl':'https://contoso.sharepoint.com','serverRelativeUrl':'/sites/SPConnect/SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Green.png', 'id':'$($imageFileUniqueId)'}"}
Update SharePoint list item with Image column in SharePoint online using PnP PowerShell
Update SharePoint list item with Image column

Note: This blog post is updated based on the updates to PnP script sample at Add/Update Image in SharePoint Image column so that added/updated images will work in Power Apps or Microsoft Lists mobile app.

Learn more

❌
❌