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

Community site session details

Session Id : uW+cLAntP9mL0VP8Ew9Ta/
Power Automate - Building Flows
Unanswered

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

Like (0) ShareShare
ReportReport
Posted on 4 Aug 2021 15:54:48 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

I have the same question (0)
  • MladenJ Profile Picture
    10 on 26 Aug 2021 at 07:07:08
    Re: Update File viewer web part in Sharepoint page when new file is created

    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 🙂

  • Expiscornovus Profile Picture
    32,205 Most Valuable Professional on 05 Aug 2021 at 15:23:30
    Re: Update File viewer web part in Sharepoint page when new file is created

    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 05 Aug 2021 at 14:57:41
    Re: Update File viewer web part in Sharepoint page when new file is created

    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')}"}

     

  • MladenJ Profile Picture
    10 on 05 Aug 2021 at 07:49:36
    Re: Update File viewer web part in Sharepoint page when new file is created

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

  • Expiscornovus Profile Picture
    32,205 Most Valuable Professional on 04 Aug 2021 at 16:26:41
    Re: Update File viewer web part in Sharepoint page when new file is created

    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?

     

     

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2