cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
flavioPBadmin
Helper I
Helper I

Creating a News Post on Sharepoint when word is mentioned in Teams Channel with the body and subject of that message

 Hi all!

I am trying to get a flow to create a news post on Sharepoint. Everything seems to be triggering correctly, but the Sharepoint page that is created is totally empty.

I suspect that this is due to the code used in the 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\":\"@{outputs('Get_message_details')?['body/body/content']}\",\"emphasis\":{}},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Title":"@{outputs('Get_message_details')?['body/subject']}"}

 

Screenshots of the flow:

Screenshot 2022-04-14 17.18.03.png

Screenshot 2022-04-14 17.26.55.png

 

Screenshot 2022-04-14 17.18.27.png

 

Screenshot 2022-04-14 17.18.37.png

Screenshot 2022-04-14 17.18.44.png

Screenshot 2022-04-14 17.18.56.png

Any ideas or suggestions on how to make this work?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @flavioPBadmin :

Please check the value of 'innerHTML'(Please use plain HTML text, do not add anything else). I've made a test and it worked well:

{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test nº 999\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"Test nº 999","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"<P>Hi bof</P>\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}

vbofengmsft_0-1650446835510.png

The Result:

vbofengmsft_1-1650446891391.png

 

Best Regards,

Bof

 

 

View solution in original post

7 REPLIES 7
v-bofeng-msft
Community Support
Community Support

Hi @flavioPBadmin ,


I've made a test but it worked well on my side:

vbofengmsft_1-1650264090403.png

vbofengmsft_2-1650264108933.png

 

 

 

vbofengmsft_0-1650264060312.png

Please try this body:


{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"@{variables('PageName')}\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"@{variables('PageName')}","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"@{outputs('Compose')}\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}

 

Best Regards,

Bof

 

flavioPBadmin
Helper I
Helper I

Just a question. How do I do to solve the error, I can't seem to be able to initialize a variable anywhere.

 

"The variable 'PageName' must be initialized before it can be used inside action 'Send_an_HTTP_request_to_SharePoint_3'.'." ?

 

flavioPBadmin
Helper I
Helper I

After some trial and error, I have gotten to this body:

{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"@{outputs('Get_message_details')?['body/subject']}\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"@{outputs('Get_message_details')?['body/subject']}","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"@{outputs('Compose')}\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}

 

Which outputs this:

{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test nº 999\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"Test nº 999","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#teams('9893b60b-98f1-479a-a274-71cabc0e8a18')/channels('19%3AXg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1%40thread.tacv2')/messages/$entity","id":"1650377165586","replyToId":null,"etag":"1650377165586","messageType":"message","createdDateTime":"2022-04-19T14:06:05.586Z","lastModifiedDateTime":"2022-04-19T14:06:05.586Z","lastEditedDateTime":null,"deletedDateTime":null,"subject":"Test nº 999","summary":null,"chatId":null,"importance":"normal","locale":"en-us","webUrl":"https://teams.microsoft.com/l/message/19%3AXg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1%40thread.tacv2/1650377165586?groupId=9893b60b-98f1-479a-a274-71cabc0e8a18&tenantId=ce0df492-7f32-43cf-b297-ee135760da1b&createdTime=1650377165586&parentMessageId=1650377165586","policyViolation":null,"eventDetail":null,"from":{"application":null,"device":null,"user":{"id":"a7fcb8b1-a5cc-4133-9756-f48cfff228d6","displayName":"Flavio Neto","userIdentityType":"aadUser"}},"body":{"contentType":"html","content":"<div>\n<div itemprop=\"copy-paste-block\">\n\n<div style=\"font-size:14px\">\n\n<p><span style=\"font-size:12pt\"><span>Hi everyone!</span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span></span></span>&nbsp;</p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>In our effort to streamline our working relationships, I would like to ask everyone to start using this team’s calendar to note down anything that might impact the whole team like, for example, create a recurring event regarding when you are regularly away from your desk, or working in another personal projects or jobs. </span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>As most of us have different work schedules, sometimes radically so, it would help us as a team to share those timings and lay them out. </span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>I would also ask for everyone to put down their annual leave dates and any other team relevant events. </span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span>Of course, you can still access other people’s personal calendars, and see their availability, but this method can give us, briefly, an idea of how much of our team is available and when.</span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span></span></span>&nbsp;</p>\n\n\n\n<p><span style=\"font-size:12pt\"><span> Please see mine and Adam’s entries in the calendar as an example.</span></span></p>\n\n\n\n<p><span style=\"font-size:12pt\"><span> #NEWS</span></span></p>\n\n</div>\n</div>\n</div>","plainTextContent":"\n\n\n\n\nHi everyone!\n\n\n\n&nbsp;\n\n\n\nIn our effort to streamline our working relationships, I would like to ask everyone to start using this team’s calendar to note down anything that might impact the whole team like, for example, create a recurring event regarding when you are regularly away from your desk, or working in another personal projects or jobs. \n\n\n\nAs most of us have different work schedules, sometimes radically so, it would help us as a team to share those timings and lay them out. \n\n\n\nI would also ask for everyone to put down their annual leave dates and any other team relevant events. \n\n\n\nOf course, you can still access other people’s personal calendars, and see their availability, but this method can give us, briefly, an idea of how much of our team is available and when.\n\n\n\n&nbsp;\n\n\n\n Please see mine and Adam’s entries in the calendar as an example.\n\n\n\n #NEWS\n\n\n\n"},"channelIdentity":{"teamId":"9893b60b-98f1-479a-a274-71cabc0e8a18","channelId":"19:Xg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1@thread.tacv2"},"attachments":[],"mentions":[],"reactions":[],"messageLink":"https://teams.microsoft.com/l/message/19%3AXg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1%40thread.tacv2/1650377165586?groupId=9893b60b-98f1-479a-a274-71cabc0e8a18&tenantId=ce0df492-7f32-43cf-b297-ee135760da1b&createdTime=1650377165586&parentMessageId=1650377165586","threadType":"channel","teamId":"9893b60b-98f1-479a-a274-71cabc0e8a18","channelId":"19:Xg-phSCY-kuv4pLCT-o8vuLDufrKkm_ho0dBmw-0Wvo1@thread.tacv2"}\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}

 

But still creates pages like this: 

 

Screenshot 2022-04-19 15.25.05.png

 

Hi @flavioPBadmin ,

 

Cause you did not Initialize the variable 'PageName'. If you want to specify the name of the Page directly, then you can replace 

@{variables('PageName')}

 with any string you want.

 

Best Regards,

Bof

flavioPBadmin
Helper I
Helper I

Hi @v-bofeng-msft,

Yes, that was what I did, and it generated the code in the post above, but the pages are still empty and I can't understand why.

 

Best regards,

Flávio

 

Best regards

Hi @flavioPBadmin :

Please check the value of 'innerHTML'(Please use plain HTML text, do not add anything else). I've made a test and it worked well:

{"__metadata":{"type":"SP.Publishing.SitePage"},"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\":\"/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG\"},\"links\":{},\"customMetadata\":{\"imageSource\":{}}},\"dataVersion\":\"1.4\",\"properties\":{\"imageSourceType\":2,\"title\":\"Test nº 999\",\"textAlignment\":\"Left\",\"showPublishDate\":false,\"authors\":[],\"showTopicHeader\":false,\"authorByline\":[],\"layoutType\":\"CutInShape\",\"titlePlaceholder\":\"Name your news post\",\"topicHeader\":\"\",\"hasTitleBeenCommitted\":false},\"reservedHeight\":306}]","AuthorByline":[],"TopicHeader":"","Title":"Test nº 999","BannerImageUrl":"/_layouts/15/images/sitepagethumbnail.png","CanvasContent1":"[{\"controlType\":4,\"id\":\"1212fc8d-dd6b-408a-8d5d-9f1cc787efbb\",\"position\":{\"controlIndex\":2,\"sectionIndex\":1,\"sectionFactor\":12,\"zoneIndex\":1,\"layoutIndex\":1},\"addedFromPersistedData\":true,\"emphasis\":{},\"innerHTML\":\"<P>Hi bof</P>\"},{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]","Categories":""}

vbofengmsft_0-1650446835510.png

The Result:

vbofengmsft_1-1650446891391.png

 

Best Regards,

Bof

 

 

flavioPBadmin
Helper I
Helper I

Thanks, that worked, now I just have to sort out how to get the body and the subject of the Teams message unto there. Will test out some ideas and come back later.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,799)