Wednesday, May 15, 2019

Approve a document in Teams using Adaptive Cards and Flow

Co-incidentally the same scenarios often appear simultaneously from different people at the same time, and this is one of them.

I’ve been assisting with random comments to a client who wants to start an approval on a document, and have that show up as a card with Approve/Decline buttons in Teams. And yesterday the good SharePoint/Flow man himself Chaks at Microsoft reached out with a similar scenario.

Chaks wanted to build a bot for this, and I asked if he had tried the Adaptive Card action in Flow, and have card buttons trigger an approval/decline action via a HTTP trigger. Turns out that adaptive cards via Flow in Teams does not support Action.Http. End of story.

Here I am, having told a client this should be easy, and Chaks telling me I can’t do it. Being me, that’s not acceptable, of course it can be done – and turns out my ego was right this time :D (it’s not always)

Start the approval Flow from SharePoint.

Adaptive card in Teams.

Important: Enable Major, minor versioning and approval on the document library. And I have not put any thoughts into licensing of actions in Flow if any for this scenario.

How??? Let me show you!

Friday, May 3, 2019

Gotcha in Microsoft Flow when modifying properties on a newly created file

This one is a common task, something I've set up a quadrillion times with workflows and event receivers in SharePoint over the past decade or so. And now the time has come to using Microsoft Flow.

The scenario is that when a file is created, you have a piece of business logic which should set metadata on the file. It could be a status flag, a serial number - the business cases are many and diverse.

Read on, young apprentice (you know who you are :) )

Thursday, May 2, 2019

How to: Creating modern page templates, and retrofitting old pages as templates

Microsoft is in the process of rolling out modern page templates, which is something we've been waiting for for a good long while now. And finally the time has come :)

I've seen it in most tenants, but not all - so be patient as it's trickling in.

If you haven't tested this yet I'll do a quick walk-thru.

To create a template you perform the following steps: Create a new modern page, add all there is to it, hit publish, and you get the option to save the page as a template as seen in the image below.

Note: The option to save as a template only show the first time you publish, but the option is available if you click the Promote button on a page as well.

Once you have created a template it will show up when you click New page from the menu on any existing modern page (it does not show while in the Site Pages library or the cog wheel Add a page at the time of writing).

What if you have existing pages you want to use as templates? One option is to start a new page with Copy of this page, and follow the steps above. Then delete the original page you used as a template as well as your new copy.

But as we're all savvy modern users we know it's simpler. If  you look at how the template feature is actually implemented, you will quickly get the drift. Once you create your first template a folder named Templates is created in the Site Pages library and any page in this folder will show as a template.

Note: If the file you move has been published as a major version at one time or another, the template will also show in search. Same goes if you turn off minor versioning on the Site Pages library. So you might want to create a template from that file instead, and then delete the files still....

This means you can retro-fit existing templates in a site performing the following steps:
  • Create a dummy template in order to have the Template folder created and enabled for templating.
  • Select the page you want as a template, and drag/move it to the Templates folder, as there is no move command on the Site Pages library.
  • Navigate to the Templates folder and open the page and you see it's now been templaty'fied
When you now want to create a new page, the template will show up as easy as corral balls!

For the techies out there

A big thank you to Erwin Van Hunen for helping on this one.

If you manually want to set up the templating feature, say in a provisioning scenario, do the following:

  • Create a folder in Site Pages (name it whatever you want) and record the unique guid of the folder

    $f = Get-PnPFolder  SitePages/MyTemplates -Includes UniqueId
  • In the property bag of the Site Pages library, set vti_TemplatesFolderGuid to that guid

    Set-PnPPropertyBagValue -Key "vti_TemplatesFolderGuid" -Value $f.UniqueId -Folder "SitePages"