cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thressac
Frequent Visitor

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User II
Super User II

Hi @PrasadAthalye ,

 

Sorry to bud in. But I think @thressac is talking about SharePoint news posts (pages with promoted state of 1 or 2).

 

If you are talking about another type of news posts, ignore my example below  😁

 

test_newspost.png

 

 

You could create these via the SharePoint REST API. Below is an example.

 

1. Add a when an item is created trigger action. Configure it to use a list.
In my example this CMS_NewsPosts list has two columns, Title and Description (both single line of text type).whenanitemiscreated.png

 

2. Add a Send an HTTP request to SharePoint action. For the creating of the draft news post. Use the site address field for the destination site of the page.

 

URI

/_api/sitepages/pages

 

Body

{"__metadata":{"type":"SP.Publishing.SitePage"},"PromotedState":1,"PageLayoutType":"Article"}

 

restapi_createpage_newspost.png

 

3. Add a Send an HTTP request to SharePoint action. For the checkout of the page. 

 

URI

/_api/sitepages/pages(@{outputs('Send_an_HTTP_request_to_SharePoint')?['body']?['d']['Id']})/checkoutpage

 

restapi_checkoutpage_id.png

 

4. Add a Send an HTTP request to SharePoint action. The title and the text within the page are set.

In this example I am using the Title and a Description field from the trigger action.

 

URI

_api/sitepages/pages(@{outputs('Send_an_HTTP_request_to_SharePoint')?['body']?['d']['Id']})/SavePageAsDraft

 

Body

{
"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\":false,\"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']}\",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Title":"@{triggerOutputs()?['body/Title']}"}

 

restapi_savepageasdraft.png

View solution in original post

3 REPLIES 3
PrasadAthalye
Super User
Super User

Can you please clarify what do you mean by a new post? Are you referring to a Twitter post?

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community
Expiscornovus
Super User II
Super User II

Hi @PrasadAthalye ,

 

Sorry to bud in. But I think @thressac is talking about SharePoint news posts (pages with promoted state of 1 or 2).

 

If you are talking about another type of news posts, ignore my example below  😁

 

test_newspost.png

 

 

You could create these via the SharePoint REST API. Below is an example.

 

1. Add a when an item is created trigger action. Configure it to use a list.
In my example this CMS_NewsPosts list has two columns, Title and Description (both single line of text type).whenanitemiscreated.png

 

2. Add a Send an HTTP request to SharePoint action. For the creating of the draft news post. Use the site address field for the destination site of the page.

 

URI

/_api/sitepages/pages

 

Body

{"__metadata":{"type":"SP.Publishing.SitePage"},"PromotedState":1,"PageLayoutType":"Article"}

 

restapi_createpage_newspost.png

 

3. Add a Send an HTTP request to SharePoint action. For the checkout of the page. 

 

URI

/_api/sitepages/pages(@{outputs('Send_an_HTTP_request_to_SharePoint')?['body']?['d']['Id']})/checkoutpage

 

restapi_checkoutpage_id.png

 

4. Add a Send an HTTP request to SharePoint action. The title and the text within the page are set.

In this example I am using the Title and a Description field from the trigger action.

 

URI

_api/sitepages/pages(@{outputs('Send_an_HTTP_request_to_SharePoint')?['body']?['d']['Id']})/SavePageAsDraft

 

Body

{
"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\":false,\"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']}\",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Title":"@{triggerOutputs()?['body/Title']}"}

 

restapi_savepageasdraft.png

View solution in original post

@Expiscornovus, your post has been  very helpful.  I'm having a hard time with the formatting on the news post.

Can you offer some pointers?

 

And is there a way to auto post the news post?  

 

Thank you for everything!

 

thressac_0-1616513708728.png

 

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (21,079)