cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create a news post when a list item is created

Is there a flow when a new list item is created it creates a news post with the info from that list item?

37 REPLIES 37
Automaton1
Regular Visitor

Hi @Expiscornovus 

 

Your solution works!! Thank you so much.

 

I've tried to insert the banner image using the following:

{

"LayoutWebpartsContent":"[{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"\\n      Title area\\n    \",\"description\":\"\\n      Title area description\\n    \",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{\"imageSource\":\"\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test\",\"textAlignment\":\"Left\",\"showPublishDate\":true,\"authors\":[{\"id\":\"\",\"upn\":\"\",\"email\":\"\",\"name\":\"\",\"role\":\"\"}],\"showTopicHeader\":false,\"authorByline\":[\"\"],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\"},\"reservedHeight\":356}]","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"innerHTML\":\"@{triggerOutputs()?['body/Description']} <p>Congrats, @{triggerOutputs()?['body/NominatedEmployee/DisplayName']}!!</p> @{triggerOutputs()?['body/Author/DisplayName']} has just nominated you for having these values: @{variables('SCCValues')}. <br> Here is their message: @{triggerOutputs()?['body/Reasons']}.<br>\",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","AuthorByline": [],"TopicHeader": "","BannerImageUrl":"https://company.sharepoint.com/sites/TestCommunicationSite/Images1/award.png","Title":"@{triggerOutputs()?['body/Title']} Congrats @{triggerOutputs()?['body/NominatedEmployee/DisplayName']}!!"}

 

On the main site, it shows up fine however not on the page itself.

Automaton1_1-1661832209007.png

 

Automaton1_0-1661832174323.png

 

Once I click on 'Page details', its showing the banner photo on the top-right.

Automaton1_0-1661836936923.png

When I click on 'Edit' to enter the edit mode on the page and click on 'page details', it shows the default banner image.

Automaton1_1-1661837035522.png

 

Any advises would be much appreciated.

 

Thanks

Anonymous
Not applicable

Hi @Expiscornovus and @Anonymous,

i would like to follow your instructions as a total noob and beginner in Power Automate. i have problems with the beginning of the third HTTP Request using the right URI. Have you made or created something beforehand that is pretty obvious? Flowreader asks me to correct for valid reference. Can u help me out here?

I have gotten closer. Mine post but only show the image when I click on the news post. The thumbnail doesn't show until I click on the post again, click edit and then immediately update the post without changing anything. Then the image and thumbnail show up correctly. 

 

\"imageSources\":{\"imageSource\":\"/sites/PC/SiteAssets/SitePages/Test-Title/88339-Expired-stamp-PSD---PSDstamps.png\"}

 

{
	"LayoutWebpartsContent": "[{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"\\n      Title area\\n    \",\"description\":\"\\n      Title area description\\n    \",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{\"imageSource\":\"/sites/PC/SiteAssets/SitePages/Test-Title/88339-Expired-stamp-PSD---PSDstamps.png\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Expired Forms\",\"textAlignment\":\"Left\",\"showPublishDate\":true,\"authors\":[{\"id\":\"\",\"upn\":\"\",\"email\":\"yourauthor@domain.com\",\"\":\"\",\"role\":\"\"}],\"showTopicHeader\":false,\"authorByline\":[\"\"],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Expired Forms\",\"topicHeader\":\"\"},\"reservedHeight\":356}]",
	"CanvasContent1": "[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"innerHTML\":\"<b>The following documents are no longer active.</b><br><br>@{outputs('Compose_Table_to_String')}\",\"emphasis\":{},\"zoneGroupMetadata\":{\"type\":0}}]",
	"Title": "Forms Expired on @{body('Convert_time_zone')}"
}

 

ConstructionUse
Regular Visitor

@Expiscornovus Thanks for all of this Dennis. Have been able to publish a News Post after inputting a new Sharepoint item!

 

Not a coder though. I will simply have 5 different data entries in the sharepoint item (location, type of building, ate when the project starts, the client, ...)

 

I would want to write the copy and add that available dynamic content. 

 

Which code do I need to add so that I can type the standard message and add the dynamic content in in between the 'Body'? 

 

Alvast bedankt. No problem if there is a guide you can direct me to...also that will help. 

Hello Atolson, Were you able to resolved this? If yes, can you please guide me as well on this?

Hi Fatimah,

I'm having a similar issue trying to copy the description field which is quite long. I guess is connected with the sharepoint webpart. Power automate goes in timeout and the created page is empty.

Have you managed to find a solution for this?

Thank you in advance, Pas

unicorn_friend
Frequent Visitor

This question is a few years old, has a new (and hopefully) improved way been developed? I've tried to recreate this solution but keep getting errors. I am quite novice at SharePoint so I'm sure it's me...

I have not had the need to look at this topic for quite a long time, but I wonder if the new Sharepoint functions in the GraphAPI will make the flow for creating a page easier. The beta version of GraphAPI now has create page as an option.  https://learn.microsoft.com/en-us/graph/api/sitepage-create?view=graph-rest-beta&WT.mc_id=email&shar... 

 

Other than that, I don't think I can be of any help on this topic anymore.  Best of luck.

jleystral
Helper II
Helper II

Hi guys, everything works well. But I have Problems to insert a hyperlink or a table. If I just insert <p>This is a test</p> within the innerHTML, everything is perfect. But if I try to insert a table or a hyperlink, the workflow have a time out everytime. Can someone help?

uriComponentToString(replace(uriComponent(variables('ExpiredFormsTable')), '%0A', ''))

 

You need to clean things up with the uriComponentToString function.

 

Thoman_0-1683635537274.png

Thoman_1-1683635654051.png

 

 

CentralAZSupply
New Member

 

 

Hi Folks, 

 

Revisiting this solution in 2023. I am using it almost successfully. I keep getting a 502 bad gateway error whenever I try to save the post as a draft. The first two calls to create && then checkout the article work fine.

 

I have two string variables that I am passing in as the title and body

Here is my body:

 

{
    "LayoutWebpartsContent": "[{\"id\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"instanceId\":\"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788\",\"title\":\"Title area\",\"description\":\"Title Region Description\",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{\"imageSource\":\"https://cdn.hubblecontent.osi.office.net/m365content/publish/5c83eb08-11a5-41e8-baa1-f1a90bd8381d/1174370562.jpg\"},\"links\":{},\"customMetadata\":{\"imageSource\":{\"width\":3015,\"height\":2012}}},\"dataVersion\":\"1.4\",\"properties\":{\"title\":\"@{variables('Article Title')}\",\"imageSourceType\":2,\"titlePlaceholder\":\"Name your news post\",\"layoutType\":\"FullWidthImage\",\"textAlignment\":\"Left\",\"showTopicHeader\":false,\"showPublishDate\":false,\"topicHeader\":\"\",\"enableGradientEffect\":true,\"isDecorative\":true,\"authors\":[{\"id\":\"user@someuserstuff\",\"email\":\"jamies@someuserstuff\",\"name\":\"User\",\"role\":\"Dept HR\"}],\"authorByline\":[\"user@someuserstuff\"],\"hasTitleBeenCommitted\":true,\"imgHeight\":2012,\"imgWidth\":3015},\"containsDynamicDataSource\":false,\"reservedHeight\":228},{\"id\":\"1ee8960a-2fa0-4145-b9bb-e818f6cf18e7\",\"instanceId\":\"1ee8960a-2fa0-4145-b9bb-e818f6cf18e7\",\"audiences\":[],\"serverProcessedContent\":{\"htmlStrings\":{},\"searchablePlainTexts\":{},\"imageSources\":{},\"links\":{\"baseUrl\":\"https://someuserstuff.sharepoint.com/sites/Intranet\"},\"componentDependencies\":{\"layoutComponentId\":\"8ac0c53c-e8d0-4e3e-87d0-7449eb0d4027\"}},\"dataVersion\":\"1.0\",\"properties\":{\"hideWebPartWhenEmpty\":true,\"isEditMode\":true,\"isEnabled\":true,\"layoutId\":\"FilmStrip\",\"uniqueId\":\"bd47ca69-bced-4624-a956-f65af668095c\",\"dataProviderId\":\"RecommendedItems\",\"webId\":\"3a9debf6-2fd7-4f8f-982c-da76d3a82c3b\",\"siteId\":\"90e145e3-d403-4a29-ba55-3a52cce305bf\"},\"containsDynamicDataSource\":false,\"reservedHeight\":356}]",
    "CanvasContent1": "[{\"controlType\":4,\"id\":\"255321be-1a48-400a-bf67-bd8b8c30ad3e\",\"innerHTML\":\"<p>@{variables('Article body')}</p>\",\"position\":{\"layoutIndex\":1,\"zoneIndex\":1,\"sectionIndex\":1,\"sectionFactor\":12,\"controlIndex\":1},\"addedFromPersistedData\":true},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true,\"isSpellCheckEnabled\":true,\"globalRichTextStylingVersion\":0,\"rtePageSettings\":{\"contentVersion\":5},\"isEmailReady\":false}}]",
    "AuthorByline": [
        "user@someuserstuff"
    ],
    "TopicHeader": "",
    "BannerImageUrl": "https://cdn.hubblecontent.osi.office.net/m365content/publish/5c83eb08-11a5-41e8-baa1-f1a90bd8381d/1174370562.jpg",
    "Title": "@{variables('Article Title')}"
}

 

CentralAZSupply_0-1692654986295.png

 

 

Anyone run into this? 

 

I was running into something similar, and applied Thoman's fix (posts above yours,, one much earlier on page 1 of the thread--even though both are re: tables).  I was getting BadGateway and deserialization errors any time my Title contained spaces.  I just wrapped that in uriComponentToString().  E.g.

"Title":"@{uriComponentToString(triggerOutputs()?['body/subject'])}"

 

Comparing the raw input in that step for the failures and the post-uri-encoded version, I do not see a difference in the spaced title, but it works...  Kudos to Thoman for the inspiration.

Thoman
Helper IV
Helper IV

Group effort! I am still having an issue where the thumbnail photo isn't created but the post has the picture. If I click edit on the created post and publish it again... the thumbnail image shows. Anyone figure that one out?

Great solution!

arine1901
New Member

Hi, 

 

I've followed those steps, but they only seem to work successfully for the specified Plain Text type. Whenever I try to use the Enhanced rich text (allowing rich text with pictures, tables, and hyperlinks) type, I consistently encounter a BadGateway error. How can I resolve this issue?

Thank you & Regards!

Hi Thoman, thanks for sharing! Is there a different way when including a link? Trying this approach timed out the flow for me.. What needs to be done when wanting to include a clickable dynamic hyperlink in the news post? Thanks!

Schwartz_Cory
Resolver I
Resolver I

Hi everyone, I was able to create a news post from a list item successfully without any premium connectors. Here is my full tutorial on the topic.

 

  1. You first need to create a news post (dont save as draft/publish it yet!) to use as a template. Load it up with the webparts and text you want. Please note, I only tested the text webpart and people webpart, but this should be capable with other webparts as well. For the parts you want to dynamically put in, insert a recognizable text. In my examples, I will be using %variable1% as my dynamic text. This will help us later on 
    Schwartz_Cory_0-1706298528137.png

     

  2. You have loaded your news post and you have not saved as draft/published, you need to open your web browsers developer tools > Network Tab > Record Button = On
    Schwartz_Cory_2-1706298763620.png

  3. With the recording on, post the news, stop the record button, and look for the "SavePage" Payload.
    Schwartz_Cory_4-1706299436426.png

     

  4. There should be a way for you to "view source" of the payload. we need this for later! I recommend you copy and paste all of it into notepad for now. 

    Schwartz_Cory_5-1706299497816.png

  5. Now we have everything we need, lets create the workflow. I am using "when an item is created" trigger from sharepoint list
    Schwartz_Cory_6-1706299732928.png

     

  6. Action 1: SharePoint HTTP Request to copy the page
    Schwartz_Cory_7-1706299899470.png

 

/_api/web/getfilebyserverrelativeurl('/sites/@{variables('varSiteName')}/SitePages/@{variables('varTemplatePageName')}.aspx')/copyto('/sites/@{variables('varSiteName')}/SitePages/@{variables('varNewPageName')}.aspx')

 

  •  Get file metadata 
    Schwartz_Cory_8-1706299955984.png

 

SitePages%2f@{variables('varNewPageName')}.aspx

 

  •  SP HTTP Request
    Schwartz_Cory_9-1706300003375.png

 

_api/sitepages/pages(@{outputs('Get_file_metadata')?['body/ItemId']})/CheckOutPage



 

  •  SPO HTTP Request - Save Page. This is where that long metadata stuff comes in. I couldnt fit all of mine in the screenshot, but you paste it in, go through line by line and replace your %variables% with your trigger list items.
    Schwartz_Cory_10-1706300149253.png

 

_api/sitepages/pages(@{outputs('Get_file_metadata')?['body/ItemId']})/savepageasdraft




 

  •  Optional. If you have the issue like me, where the date of the news post was not correct, add this action in.
    Schwartz_Cory_11-1706300227478.png

 

_api/web/lists/GetByTitle('Site Pages')/items(@{outputs('Get_file_metadata')?['body/ItemId']})/validateUpdateListItem
convertFromUtc(utcNow(), 'Eastern Standard Time', 'g')




 

  •  Optional. If you have comments and want to turn them off, this is how:
    Schwartz_Cory_12-1706300283339.png

 

_api/web/lists/GetByTitle('Site Pages')/GetItemById(@{outputs('Get_file_metadata')?['body/ItemId']})/SetCommentsDisabled



 

  •  HTTP Request - publish!!
    Schwartz_Cory_13-1706300326295.png

 

_api/SitePages/pages(@{outputs('Get_file_metadata')?['body/ItemId']})/Publish 



 

  •  And test your flow! NOTE: if you are testing multiple times, make sure you delete the news post before reruning the test again, SPO will not create a news post of a page that already exists. Or ignore me and you will run into the error on your own ;p.

 

Thanks for this awesome thread and hope this help put this problem to rest!

Very good solution Expiscornovus, which I still have to modify for our purposes. We use special templates, how can I specify the template to be used in the "send an HTTP request" steps? What is the syntax if I want to add several fields:
"innerHTML\":\"@{triggerOutputs()?['body/Description']}\","innerHTML\":\"@{triggerOutputs()?['body/Price']}\","innerHTML \":\"@{triggerOutputs()?['body/Date']}\",
Would that work?

Helpful resources

Announcements

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (5,895)