web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Update File viewer web...
Power Automate
Unanswered

Update File viewer web part in Sharepoint page when new file is created

(0) ShareShare
ReportReport
Posted on by 10

Hi there,

 

I'm new to Power Automate and i'm looking for some guidance (solution, tutorial, etc.) 

 

The scenario is simple and it goes like this:

1. Each week report is being updated and saved as a PDF, which is uploaded to a Sharepoint folder - PDF

2. Once the file is saved, i need to copy the link of the file and go over to our team's Sharepoint page, edit the page and change the link in File Viewer web part.

 

At the moment, i'm doing the second step manually and of course, i would like that to be automated.

 

Is there a way to update the link to an existing File viewer web part in Sharepoint page via Power Automate when the new file is created in the PDF folder?

 

Any suggestion would be helpful. Thanks

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,874 Most Valuable Professional on at

    Hi @MladenJ,

     

    It would be possible via a Send an HTTP request to SharePoint action and the savepageasdraft method. In the body of that request you can update for example the file url within the Document Embed Web Part (b7dd04e1-19ce-4b24-9132-b60a1c2b910d).

     

    However, it does require some json in the body of that request. I have seen a similar requirement in this thread:

    https://powerusers.microsoft.com/t5/Building-Flows/Publish-dynamic-document-with-File-Viewer-in-a-SP-Page/m-p/829372/highlight/true#M115924

     

    That thread might help to get you started?

     

     

     

  • MladenJ Profile Picture
    10 on at

    Thanks for the swift reply @Expiscornovus, i'll be sure to check that out.

  • MladenJ Profile Picture
    10 on at

    Hi again @Expiscornovus,

     

    I have managed to create a flow (including all variables), but i'm struggling with json part from the post you mentioned.

     

    I don't have a clue about json coding, but what i can read is that there is no reference to my File Viewer web part on the page. I see that by Use Case Title we can "navigate" to the page we want, but i don't get it how to point the code to specific File Viewer. 

    Additionally, i see the List is being used. But, i'm not sure how to change to to point to a Folder?

     

    Also, i'm getting an error in the flow:

    Correct to include a valid reference to 'Get_file_properties' for the input parameter(s) of action 'Send_an_HTTP_request_to_SharePoint

     

    Current flow looks like this:
    err.png

    Step Send an HTTP request to SharePoint looks like this:
    step.png
    The code:

    {"LayoutWebpartsContent":"[{\"id\":\"@{variables('PageTitleWebPartId')}\",\"instanceId\":\"@{variables('PageTitleWebPartId')}\",\"title\":\"\",\"description\":\"\",\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{},\"links\":{}},\"dataVersion\":\"1.4\",\"properties\":{\"title\":\"@{variables('Use Case Title')}\",\"imageSourceType\":4,\"layoutType\":\"FullWidthImage\",\"textAlignment\":\"Left\",\"showTopicHeader\":false,\"showPublishDate\":false,\"topicHeader\":\"\",\"authors\":[],\"authorByline\":[\"@{outputs('Get_file_properties')?['body/Author/Email']}\"]},\"reservedHeight\":228}]",
    "CanvasContent1":"[{\"controlType\":3,\"id\":\"@{variables('CanvasContent1ControlId')}\",\"position\":{\"zoneIndex\":1,\"sectionIndex\":1,\"controlIndex\":1,\"layoutIndex\":1},\"webPartId\":\"@{variables('DocumentEmbedWebPartId')}\",\"webPartData\":{\"id\":\"@{variables('DocumentEmbedWebPartId')}\",\"instanceId\":\"@{variables('CanvasContent1ControlId')}\",\"title\":\"File viewer\",\"description\":\"\",\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{\"title\":\"@{outputs('Get_file_properties')?['body/{Name}']}\"},\"imageSources\":{},\"links\":{\"serverRelativeUrl\":\"@{replace(outputs('Get_file_properties')?['body/{Link}'], variables('RootUrl'), '')}\",\"wopiurl\":\"@{outputs('Get_file_properties')?['body/{Link}']}\"}},\"dataVersion\":\"1.4\",\"properties\":{\"annotation\":\"\",\"authorName\":\"@{outputs('Get_file_properties')?['body/Author/DisplayName']}\",\"chartitem\":\"\",\"endrange\":\"\",\"excelSettingsType\":\"\",\"file\":\"@{outputs('Get_file_properties')?['body/{Link}']}\",\"listId\":\"@{variables('FileViewerSourceListId')}\",\"modifiedAt\":\"@{utcNow()}\",\"photoUrl\":\"@{replace(outputs('Get_file_properties')?['body/Author/Picture'], concat(variables('SiteUrl'),'/_layouts/15/UserPhoto.aspx?Size=L'), '/_layouts/15/UserPhoto.aspx?Size=S')}\",\"rangeitem\":\"\",\"siteId\":\"@{variables('SiteId')}\",\"startPage\":1,\"startrange\":\"\",\"tableitem\":\"\",\"uniqueId\":\"@{replace(replace(split(outputs('Get_file_metadata')?['body/ETag'], ',')?[0], '"{', ''), '}', '')}\",\"wdallowinteractivity\":true,\"wdhidegridlines\":true,\"wdhideheaders\":true,\"webId\":\"@{variables('WebId')}\",\"webAbsoluteUrl\":\"@{variables('SiteUrl')}\"}},\"emphasis\":{},\"reservedHeight\":686,\"reservedWidth\":1180,\"addedFromPersistedData\":true},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","AuthorByline":["@{outputs('Get_file_properties')?['body/Author/Email']}"],"TopicHeader":"","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","Title":"@{variables('Use Case Title')}"}

     

  • Expiscornovus Profile Picture
    33,874 Most Valuable Professional on at

    Hi @MladenJ,

     

    In the example of the previous thread I was using a action Get file properties. However, you are using a different action, Get file metadata.

     

    When you are reusing the code snippet you have to search and replace to use the properties of your get file metadata action instead of the Get File properties action.

     

    To give you an example. 

     

     

    @{outputs('Get_file_properties')?['body/{Name}']}

     

     

     

    In your case that would be:

     

     

    @{outputs('Get_file_metadata')?['body/{Name}']}

     

     

     

  • MladenJ Profile Picture
    10 on at

    Hey, just wanted to provide an update on the post.

     

    So, i haven't figured out the way with the json input, but i managed to get a workaround.

     

    Each time a new file is created, a copy of that file is made to our team's SHP site with constant name. 

    I have used the link from that constant file in the File preview object so basically it keeps showing the latest file each time without updating a link.

     

    Thanks for the help though @Expiscornovus, but json is out of my reach 🙂

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 976

#2
Valantis Profile Picture

Valantis 863

#3
Haque Profile Picture

Haque 547

Last 30 days Overall leaderboard