cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mattw112IG
Impactful Individual
Impactful Individual

Using Flow to change banner image and image on a page in Sharepoint

I have some code that creates new site pages.

Basically it uses a template and fills in the blanks.

However even though I'm putting in a path to an image stored in my site assets it doesn't change from the original picture.  It is not giving me any errors but the images don't change. 

Is this known problem?

 

Does anyone know how to change a banner image or image webpart on a modern site page using SharePoint REST?

 

Thanks,

Terry

11 REPLIES 11
ChristianAbata
Super User II
Super User II

hi @Mattw112IG  I'm shure this post can help you

https://n8d.at/how-to-define-default-header-image-for-events-in-communication-site-and-a-user-story/

 

I hope this can helps.

 


Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

I came across this too, but it is confusing to me.

 

When I go to "Update Item" it wants a list not site pages?  It does look like I may be able to set using the "Update File Properties" command though.  I will try that.

 

Also this is for just the banner I also have a web part on the page with an image I'd like to change.

 

Thanks,

Terry

mmm @Mattw112IG  I was looking into official docs and it looks like that are not supported jet.

 

see the

UpdateSiteDesign

 

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-rest-api



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

Not sure if site design is same as page changes?

 

I am able to customize most of the pages with text fields.  Just the image field I am having a challenge with.

 

Thanks,

Terry

Mattw112IG
Impactful Individual
Impactful Individual

Also here's the part of my JSON with the image but I wonder if I have to know a Unique ID? I'm just setting the full path and name..("/sites/msd/IandI/MSDToolbox/SiteAssets/Logos/Clients/customer.png\"}). Not sure how I would find a unique ID for an image in site assets?

 

\"imageSources\":{\"imageSource\":\"/sites/msd/IandI/MSDToolbox/SiteAssets/Logos/Clients/customer.png\"},\"links\":{},\"customMetadata\":{\"imageSource\":{\"siteId\":\"14a39437-bfba-4008-9276-f3a978cc53ea\",\"webId\":\"45743f31-e225-4b08-9cfa-26c40e4feda1\",\"listId\":\"c427389c-3257-4650-8e8f-c79c86dbe813\",\"uniqueId\":\"d3554111-8878-48bb-822f-a9a816ab8f16\"}}},\"dataVersion\":\"1.4\"

 

Terry

Did you ever solve this issue? I am experiencing a similar issue attempting to update a page's image using PowerAutomate. 

 

 

Mattw112IG
Impactful Individual
Impactful Individual

I ended up just going with a generic graphic and using that for all pages.

 

 

Expiscornovus
Super User II
Super User II

Hi @Mattw112IG,

 

I managed to get this working via a Send an HTTP request action and the SavePageAsDraft method.

 

However, there are some tricky parts in that setup.

- You need to know the GUIDs of the Site, Web, List and File were the banner image is located

- It looks like you need to the GetPreview.ashx url in the BannerImageUrl field. This url however requires the same GUIDs without hyphens in them

 

Below is a couple of bits of that approach. Hopefully that already helps to get you started?

I will try and add some more explanation later on.

 

1. Use a variable to generate the BannerImageUrl.

I am using replace functions because I use the GUIDs with hyphens (in other variables)

@{variables('RootSiteUrl')}/_layouts/15/getpreview.ashx?guidSite=@{replace(variables('guidSite'), '-', '')}&guidWeb=@{replace(variables('guidWeb'), '-', '')}&guidFile=@{replace(variables('guidFile'), '-', '')}&ext=png

 

bannerimageurl.png

 

2. Use a Send an HTTP request to Post a draft page. Use the body below as an example.

Replace the variables with your own values.

 

{"LayoutWebpartsContent":"[{\"id\":\"@{variables('PageTitleWebPartId')}\",\"instanceId\":\"@{variables('PageTitleWebPartId')}\",\"title\":\"\\n      Title area\\n    \",\"description\":\"\\n      Title area description\\n    \",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{\"imageSource\":\"@{variables('AbsoluteImageUrl')}\"},\"links\":{},\"customMetadata\":{\"imageSource\":{\"siteId\":\"@{variables('guidSite')}\",\"webId\":\"@{variables('guidWeb')}\",\"listId\":\"@{variables('guidList')}\",\"uniqueId\":\"@{variables('guidFile')}\",\"width\":1617,\"height\":376}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[{\"id\":\"@{variables('UserClaim')}\",\"upn\":\"@{variables('UPN')}\",\"email\":\"@{variables('Email')}\",\"name\":\"@{variables('UserDisplayName')}\",\"role\":\"\"}],\"showTopicHeader\":false,\"authorByline\":[\"@{variables('UserClaim')}\"],\"layoutType\":\"CutInShape\",\"topicHeader\":\"\",\"altText\":\"\",\"webId\":\"@{variables('guidWeb')}\",\"siteId\":\"@{variables('guidSite')}\",\"listId\":\"@{variables('guidList')}\",\"uniqueId\":\"@{variables('guidFile')}\",\"imgHeight\":376,\"imgWidth\":1617},\"reservedHeight\":356}]","CanvasContent1":"[{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","AuthorByline":["@{variables('UserClaim')}"],"TopicHeader":"","BannerImageUrl":"@{variables('BannerImageUrl')}","Title":"Set Banner Test"}

savepageasdraft_bannerimageurl.png

 

 

Hi, 

 

That's fantastic and really helps. The main question for me is how are you getting the file/picture GUID? That is where I am struggling at the moment. 

Expiscornovus
Super User II
Super User II

Hi @Morph19041,

 

I am using another Send an HTTP request for that with this GET request:

_api/web/lists/getbytitle('Site Assets')/Items(7)?$select=GUID

 

After that you can collect the GUID via this expression. I am storing it in in variable.

outputs('Send_an_HTTP_request_to_SharePoint_-_Get_File_GUID')?['body']['d']['GUID']

 

guidfile_sharepoint.png

My create pages is all working but I was just having a hard time dynamically getting the right picture id for different cases.  So for example my company does projects for other companies.  So what I am doing today is every time we win an award I create a Win wire email with a corresponding SP Page with the details.  For the picture at the top I was going to put the logo for that customer.  But I just had other priorities.  I will look at the stuff posted above some time though once things free up.  Thanks.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,984)