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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create a news post whe...
Power Automate
Unanswered

Create a news post when a list item is created WITH FILE

(0) ShareShare
ReportReport
Posted on by 9

Hi there,

 

Based on Solved: Create a news post when a list item is created - Power Platform Community (microsoft.com),

 

I need to create a SharePoint news every time an item is added to the list. But I would like you to include the attached document.

NanaG_0-1698083262746.png

 

 

In manual creation of SharePoint news, there's the option to insert a file (File and Media), how would I do this via flow with the list attachment?

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

    Hi @NanaG,

     

    You would need to provide the json values in within the CanvasContent1 property of the page. You would use that json payload in a Send an HTTP request to SharePoint action with for example the SavePageAsDraft method of the SharePoint REST API.

     

    Have a look at this thread to get you started:

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

     

    Let me know if you need any additional help.

  • NanaG Profile Picture
    9 on at

    Hi, @Expiscornovus 
    Thanks for the reply, you always post amazing solutions.

    As I'm working with sharepoint list attachments, I don't use 'Get file properties'. I tried to adapt, but it is taking the property of the list item ID and not the attachment:

     

    NanaG_1-1698157965364.png

     

    I used the same variables as you, inserting the data obtained in the developer toolbar on a network tab.

    It's my first time working with json, maybe it's something obvious

     

     

    When I try to use the code generated in developer toolbar, a bad gateway message appears, and a completely blank draft is created, with no file and no title:

     

    NanaG_0-1698231639576.png

     

     

     

     

    {"LayoutWebpartsContent":"[{\"id\":\"@{variables('PageTitleWebPartId')}\",\"instanceId\":\"@{variables('PageTitleWebPartId')}\",\"title\":\"\",\"description\":\"\",\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{},\"links\":{}},\"dataVersion\":\"1.4\",\"properties\":{\"title\":\"@{outputs('Get_item')?['body/Title']}\",\"imageSourceType\":4,\"layoutType\":\"FullWidthImage\",\"textAlignment\":\"Left\",\"showTopicHeader\":false,\"showPublishDate\":false,\"topicHeader\":\"\",\"authors\":[],\"authorByline\":[\"@{outputs('Get_item')?['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_item')?['body/{Name}']}\"},\"imageSources\":{},\"links\":{\"serverRelativeUrl\":\"@{variables('varAbsoluteURI')}\",\"wopiurl\":\"@{variables('varAbsoluteURI')}\"}},\"dataVersion\":\"1.4\",\"properties\":{\"annotation\":\"\",\"authorName\":\"@{outputs('Get_item')?['body/Author/DisplayName']}\",\"chartitem\":\"\",\"endrange\":\"\",\"excelSettingsType\":\"\",\"file\":\"@{variables('varAbsoluteURI')}\",\"listId\":\"@{variables('varAbsoluteURI')}\",\"modifiedAt\":\"@{utcNow()}\",\"photoUrl\":\"@{replace(outputs('Get_item')?['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\":\"@{variables('varETAG')}\",\"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_item')?['body/Author/Email']}"],"TopicHeader":"","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","Title":"@{outputs('Get_item')?['body/Title']}"}

     

     

     

     

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

    Hi @NanaG,

     

    Can you share a screenshot of your current setup?

     

    If you want to retrieve the attachments and the properties of each of these attachments you could use the approach below:

     

    getattachments_list.png

     

    Or you can also try an HTTP request. That might be a bit more flexible on which properties are returned.

     

    _api/web/lists/getByTitle('<Title of Your List>')/items(@{triggerOutputs()?['body/ID']})?$select=AttachmentFiles,Title&$expand=AttachmentFiles

     

    attachmentfiles_expand.png

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard