Success page for HTTP request

From SharePoint Online you can trigger a flow by using a link or a button. In this article I will show you how to respond with a custom success page in a HTTP triggered Power Automate cloud flow.

Inspiration

This question from Ankit Jana:

I have a question related to the button- When I click on the button it opens a new tab with the url – https://prod…

Is it possible to trigger the flow (click the button) without opening a new tab with the trigger URL?

Or if we can open a new tab with a different URL (eg. success page)

Comment in one of my blogs: E-mail Me button on page.

Setting the Scene

If you didn’t read my previous blog, E-mail Me button on a page, I will share a short summary of that solution.

emailmebutton

A button was created by using column formatting and view formatting in a SharePoint list. In that formatting a hyperlink was used to trigger a flow via the When a HTTP request is received trigger action.

The button was added to the page via a List web part. And finally the hyperlink also included the email address of the user who clicked on it and the current site the button was added to using special string values.

What is missing?

The previous setup is lacking a bit of a response/feedback to the end user. When the button is clicked a new empty tab opens with the flow url. It handles the request and that is it. Like mentioned by Ankit it would be useful to customise this a bit or even better create a custom success page.

Success Page

A Response action is used in the Power Automate cloud flow to send back text and HTML. To make it easier to style the page I have used the Bootstrap framework for the CSS, HTML and JavaScript.

First of all the example uses a container with styles card in it.

The title of the card contains a text with a hyperlink to the site which this click was coming from. To demonstrate the options you have in this type of setup I have also included a gif within the text part of the card.

And finally the example also uses JavaScript to close the tab after a delay of 10 seconds. This way the end user should have seen the success page while it still closed automatically for them.

A big shout out to Paul Murana. I got my inspiration for this Response action with Bootstrap approach from his previous blogs about the HTTP actions. He has created several advanced solutions with these action. For example I can recommend having a look at the Build an easy to use File Upload tool with Dropzone and Power Automate blog.

Flow setup

This is only the cloud setup part of the solution. For the other steps like the formatting and list web part setup please check the original blog, E-mail Me button on page.

Checklist before you start:
– This example uses a Request connector action which is part of a premium feature, make sure you have a license which covers this.

httprequestreceived_response

1. Add a When a HTTP request is received trigger action.
This example uses Anyone, you might consider using the option Any user in my tenant or the Specific users in my tenant instead. But that would also mean a different setup for this solution.

anyone_http

a. Select Anyone in Who can trigger the flow
b. Select the GET method under advanced options
c. Copy the HTTP URL value, you will need it for the column formatting part.

2. Add a Get User profile (v2) action.
To retrieve the email for user who clicked the button.

getuserprofilev2_emailaddress

a. Add the expression from the code snippet below via the Expression editor to the User (UPN) field.

3. Add a Send an email (V2) action.

sendanemailv2_currentweb

a. Use the Mail dynamic content field in the To field
b. Provide a Subject value
c. Provide a Body value. In this instance I also used the displayName of the user and the site address which is hosting this news post. I used the value from the code snippet below.

4. Add a Response action.

response_http

a. Provide a Status Code value, in this case 200
b. Provide Headers, I used the Headers from the code snippet below.

c. Provide a Body value. I used the Body value from the code snippet below.

That is it for the cloud flow setup of this example.

Testing

The result should look like the below
emailhasbeensent

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.