Email Hyperlink to Form

Over the years I’ve written a few posts about hyperlinks in SharePoint, and emailing hyperlinks.  Now with Power Apps, I’m getting this question pretty often.  In this post, I’ll explain how to send a hyperlink to an item in SharePoint, in an email from PowerApps, and how to do it in Flow as well.

Here are my related posts:

Workflow: Create a hyperlink

InfoPath Email Link to Browser Form

Custom Hyperlink Icon Column

SharePoint URL Basics

First of all, there’s a huge difference between sending a link to a SharePoint list item that’s been customized with PowerApps, and sending a link to a standalone PowerApp, to a specific item.  This post is about customized SharePoint list forms, not standalone apps.

The syntax for the link to a SharePoint list item is:

SITEURL/lists/LISTNAME/newform.aspx

SITEURL/lists/LISTNAME/dispform.aspx?ID=X

SITEURL/lists/LISTNAME/newform.aspx?ID=X

 

In the above, X is the unique ID of the item in the list.  Everything in every SharePoint list and library has an ID that is unique in that list.

So an example URL to get directly to the edit form for item number 5 in my travel list is:

https://wonderlaura.sharepoint.com/sites/travelsite/lists/travel/editform.aspx?ID=5

In most cases in my experience, people want to get the link directly to the edit form in the email, instead of the display form.  With SharePoint Designer 2013 workflows, there’s the workflow context link to the item, and in PowerApps, there’s also a link to item field.  Both of those take you to the display form.  In order to link to the edit form, you won’t be using that default link.  Also, keep in mind that in order to send a link to an item, the item has to exist first, and has to have an ID, so with a brand new form, this is something to keep in mind.  If you’re sending a link directly from PowerApps without using Flow, the item still does have to be saved/submitted first.  So, the best standard way to do this, will be to use the OnSuccess property of the form control in PowerApps.

To send a link to the edit form, directly from PowerApps, for a list form customized in PowerApps:

  1. In PowerApps, add a connection to email if you haven’t already.  On the View menu, choose Data Sources, and if you don’t already see something that looks like this:
    outlook-data-connection-powerapps
    Click Add data source to create this if it’s not already there.  In the list of connections to add, it’s called Office 365 Outlook.
  2. In PowerApps, select your form control.  By default, it’s called SharePointForm1.  Go to the OnSuccess property. 
  3. There will probably already be a couple of actions in there, to reset the form and hide it.  You’ll be adding the send email action in front of those.  Here is the syntax:
    office365-send-email-powerapps-syntax
    As you can see, the tricky part is in the body of the email, where it starts with test link to item.  Notice the double quotes around the URL.  Also, the IsHtml is really important.  In that example, I have just hard coded the full URL to the site and list, so you’ll use your own URL in there.
  4. You can also make this dynamic, so that you can use the same formula in all of your PowerApps.  Here is the dynamic string, which uses the URL to your site and list.

Office365.SendEmail(
“tester@tester.com”,
“This is the subject”,
“test link to item <a href=””” & Left(SharePointForm1.LastSubmit.'{Link}’,Find(“_layouts”,SharePointForm1.LastSubmit.'{Link}’)-1) & SharePointForm1.LastSubmit.'{Path}’ & “EditForm.aspx?ID=” &SharePointForm1.LastSubmit.ID & “””> CLICK HERE </a>”,
{IsHtml: true}
)

Here is what this same thing would look like in a Microsoft Flow Send an Email action (Office 365 Outlook).  But of course, if you send the email directly from PowerApps, you don’t need Flow for that.

microsoft-flow-email-body-html

 

Here is my video, teaching you all about sending email directly from PowerApps:

In this video, learn how to send emails directly from within PowerApps, without the need for Microsoft Flow. Emails can even be customized with HTML, and lists of items can be sent as well.

2018-09-03_13-30-23

https://www.iwmentor.com/pages/powerapps-send-email

 

If you’re looking for instructions for doing this with a standalone app, I haven’t written a post about it yet, but I do cover it in great detail in my PowerApps Training class.  It’s much more complicated of a process.

13 comments

  • Thanks, Laura. I’m interested in learning how to send people to a specific item within a stand-alone app. Can you tell me where within the training it’s covered? I attended the class earlier this year, so I have access. Thanks.

  • Hi Laura,

    Sending a link in an email for a list item was very nice. Can you also show how to send list attachments in an email from powerapps by either using Flow or Office365 connector?

  • Jaweed Lallmahomed

    Hi Laura
    Can you please provide me details on your trainings in SharePoint. We are on office 365. I need to present to mgmt something on SharePoint.

    Thanks
    Rgds
    Jaweed

  • Hi Laura,

    Is it possible to send someone to an item in a custom list form created with PowerApps (as opposed to a stand-alone app) using a URL parameter? I added a screen to show related items in another list and I can use the gallery on the main screen to get to those. I can get to an item in the main list (the one that the PowerApp is tied to) by adding an item ID to the URL (as in dispform.aspx?ID=111) but I tried adding another parameter for the related item in the other list (e.g., dispform.aspx?ID=111&ReqID=22) and that doesn’t seem to work using the Param function, etc. like in your lesson mentioned above. It just stays on the first screen showing the item from the main list.

    Thanks,
    Dave

  • This was a great help, thanks. I was trying to find a way to tidy up how Flow displays links to sharepoint items and was able to use the example above. cheers!

  • HI Laura – I have a form that a user may or may not save prior to submitting. If the item has already been saved, I can get the ID to embed in the link using SharePointIntegration.SelectedListItemID, if they are submitting a new item, though,, SharePointIntegration.SelectedListItemID always returns 1. Is there an event I can put my logic into where the new Id will have already been acquired? If not, I’m thinking I may need to create a boolean field in my list called “Emailed” and have a Flow that emails items that have a “No” in that field and then sets the field to “Yes”. Or I’m open to other ideas. One other idea I have for now is to have my email send a link to the listed filtered by Status=Submitted, which might work out fine, too.

    • How would you send someone a link to something that doesn’t exist yet, though. Submit the item first. Then OnSuccess of that form, send the hyperlink. The action that you’re running that sends the email should just be moved to be in a place in the app that happens after the item has been submitted. frmName.LastSubmit.ID is where you can then get the ID of it.

    • Yes, that’s precisely my point. 🙂 I’ll experiment with using OnSuccess… I just need to be careful not to send the email every time the form is saved… only when the status changes. Thanks!

  • Hi
    A slightly diff question, do you know how to embed powerapps android app link sharepoint page or outlook email?
    ms-apps:///providers/Microsoft.PowerApps/apps/APPID
    which opens up the app in hte app instead of browser. It looks like outlook and sp pages only accept https hyperlinks.

    cheers

Leave a Reply