Friday, 16 September 2022

How to create custom create news button in SharePoint Online?

 Recently we were developing a custom news web part using SPFx. The functionality was required the same as the OOTB news web part. The only change was we needed a few more layout options as well we need to showcase a few more column details in the news web part. We build the remaining things as expected but we didn’t have any idea how to provide create a post button as the OOTB news web part provides.

Issue:

So, our first approach was the lazy one. We find out a URL that will create a site page and we will train users to click “Promote as news” once the page is published.
URL – [SiteURL]/_layouts/15/CreateSitePage.aspx

But the issue is, Client didn’t agree to have a 2-click solution.

Solution:

We got a blog from Shantha Kumar (link in description) that provided us an initial idea of the difference between a modern site page and a news post. Microsoft has put a parameter – “Promoted State” to differentiate the page creation.

Promoted State

Page Creation Experience

0 or null

This will create a Modern Site page.

1

This will create a News post in the draft version.

2

This will be the News Post in the published version.

 

In simple terms, if we hit the below URL, it will create the news post:
[SiteURL]/_layouts/15/CreateSitePage.aspx?promotedstate=1

This solved the first half of the issue. But Microsoft has provided different experiences in news post creation. If you are creating news posts from site pages, it will create posts from a basic template directly. But if you are creating it from the home page or any news post, it will showcase template selection.

The client asked us if it is possible to open that pane with a button click. Here we needed to research some more and ultimately our savior stack exchange has an answer for that. The updated URL will look like the below:

[SiteURL]/_layouts/15/CreatePageFromTemplate.aspx

As the information is scattered and hidden, I thought it would be useful to have this in one place. Hope this helps.  

Reference:

  • https://docs.microsoft.com/en-us/dotnet/api/officedevpnp.core.pages.promotedstate?view=sharepoint-pnpcoreol-3.2.1810
  • https://www.c-sharpcorner.com/blogs/how-the-sharepoint-works-before-creating-news-post-site-page
  • https://sharepoint.stackexchange.com/questions/275598/use-template-for-modern-page-set-page-template-for-the-content-type-site-page

Sunday, 11 September 2022

Visual Studio Code Prettier Extension Set up

Recently I needed to use the Prettier code formatter extension in visual studio code. I thought it would be similar to other extensions. But it is not. We need to set a setting for this extension to work automatically. We will go through that setting for the windows system in this blog.

Prettier Extension Set up

  • Open visual studio code as an administrator.
  • From extensions, install “Prettier – code formatter”




Once you have installed it, you can use it with CTRL + CMD + P (macOS) or CTRL + Shift + P (Windows) to manually format a file or a selection of code

Required Settings

We need to enable format on save settings for this extension. By default, it is disabled in visual studio code, and it is a manual setup.

Also, we need to set the Prettier extension as the default formatter.

Windows Machine set up

In windows, we can follow the below steps for the required settings:
  • Click settings. You will find it in the left bottom corner.


  • Click on Settings in the menu.


  • It will open the settings page. In that, click on the text editor.


  • Scroll down to “Default Formatter” settings.


  • Here, we need to select Prettier.



  • After this from the left menu click on “formatting”.


  • Here, checks the option “Format on save”.




Verify the changes

  • To verify the settings, click on the new text file from the file menu.


  • Click on select a language. Then select – HTML



  • Paste the below code and save the file.

 <html>  
 <head> <title>This is test</title> </head>  
 <body> <p>this is test</p> <p>This is test 2</p> <p>test</p> </body>  
 </html>  

  • When you save the file, it will be automatically formatted.




Final Comments 


With Prettier, the life becomes easy, and code becomes readable. However, be aware that this applies to every project now. If you happen to work on a project with a team where the project does not use Prettier, you will format every file once you save it. If not agreed upon with your teammates, this may cause trouble.

Friday, 12 August 2022

Power Automate URL Changes

 Issue:

Recently I got a query from a citizen developer about a message showing on the Power Automate home page that whether they need to worry about this or not.


 

Generally, I am not used to reading the warnings posted by Microsoft on the home page of Power Platform applications but as this was a query, I needed to look into it, and I found out that this might not be much worry on the first reading.

Analysis:

As it suggests in the message as well, when you click on the “Learn More” link, you will read similar stuff that Microsoft is changing the URL of Power automate from “https://flow.micrsoft.com” to “https://make.powerautomate.com”.

Also, it is mentioned in the article that once the changes are done, Microsoft will route all the traffic requests to the new URL and users will be redirected to new URL. Though they suggest if they can update their bookmark, it would be useful to change it to a new URL.

Below are the new URL details provided by Microsoft:

 

#

Existing Power Automate URL

New Power Automate URL

1

*.flow.microsoft.com

*.powerautomate.com

2

flow.microsoft.com

make.powerautomate.com

 

 

 

For US Government Customers

1

gov.flow.microsoft.us

make.gov.powerautomate.us

2

high.flow.microsoft.us

make.high.powerautomate.us

3

flow.appsplatform.us

make.powerautomate.appsplatform.us

 

 

 

For China Customers

1

powerautomate.cn

make.powerautomate.cn

 

 

 

But then I read it twice more to understand the impact on a bigger scale and it is actually a big change. Let’s say you have an IT administrator who has added IP config rules and is not allowing any other URL without prior approval from the network. This would break any flow running because the request would be coming from a new site and would be blocked.

This scenario can happen to Gateway connections especially. As it could be configured to interact with your local cloud.  It will also affect to US Government customers as it has strict URL policies.

 

So how do you know whether you will be affected by it or not?

There is a paragraph where Microsoft has mentioned that the image in the beginning of the post will be in red color if you are affected. This means you will be facing errors in your flow once the URL change will be implemented.

The following table lists the services to which Power Automate connects. Ensure none of these services are blocked on your network.

Domains

Protocols

Uses

management.azure.com

https

Access to the Azure Resource Manager.

login.microsoft.com
login.windows.net
login.microsoftonline.com
login.live.com
secure.aadcdn.microsoftonline-p.com

https

Access to authentication and authorization endpoints.

graph.microsoft.com

https

Access to Microsoft graph - for getting user information such as a profile photo.

*.azure-apim.net

https

Access to the Runtime for Connectors.

*.flow.microsoft.com

https

Access to the Power Automate site.

*.powerautomate.com

https

Access to Power Automate site.

*.powerapps.com

https

Access to the Power Apps site.

*.azureedge.net

https

Access to the Power Automate CDN.

nps.onyx.azure.net

https

Access to NPS (Net Promoter Score).

webshell.suite.office.com

https

Access to Office for header and search. Please see the Office 365 urls and ranges for more details.

*.dynamics.com

https

Access to Dataverse tables

go.microsoft.com

https

Access to the Power Automate to check for updates

download.microsoft.com

https

Access to the Power Automate to check for updates

login.partner.microsoftonline.cn

https

Access to the Power Automate for desktop cloud discovery

 

Note

It is not necessary that you see red flags on Power Automate home as per my understanding.  This depends on Microsoft and Your company agreement and if your company has not provided access to your network detection, you may not see this red flag.

 

For more details, please refer to below link:

·         Power Automate IP address configuration

 

This change is scheduled for the end of June as per the article. Microsoft has only initiated new sites yet. But once they release the changes, sooner or later they will block the old URL. Before that Microsoft might change the banner's color or shoot an email thread. If you want to be prepared in advance you can perform the check on IP configuration. If you still face the issue, you can always generate a ticket with Microsoft for the same.

 

Reference:

https://powerautomate.microsoft.com/en-us/blog/flow-microsoft-com-is-moving-to-make-powerautomate-com/