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?

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

 

@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.

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

 

 

 

 

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.

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!

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!

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?

Hi @Expiscornovus 

I followed your guide but upon saving the flow, I get an error in the second HTTP request, relating to the reference of the output of the first request. It says that the input parameter is invalid

 

Baen_0-1718716005611.png

 

Any idea whats wrong here?

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (878)