|
| 1 | +# Send an email when a new item is created or modified in a SharePoint list |
| 2 | + |
| 3 | +Using Microsoft Flow you can easily automate day-to-day tasks or build repetetive tasks in SharePoint that help you stay productive. |
| 4 | + |
| 5 | +In this tutorial, you will create a flow that will send an email when a new item is added or modified in a SharePoint list. |
| 6 | + |
| 7 | +## Required setup |
| 8 | + |
| 9 | +Before following the steps in this artucle, make sure your SharePoint site is set up with the required lists and libraries. |
| 10 | + |
| 11 | +## Create a flow |
| 12 | + |
| 13 | +1. Browse to the *Projects* list in your SharePoint site. |
| 14 | + |
| 15 | +2. You can create and manage flows for a list or a library by clicking on the *Flow* button on the command bar on the list or library page. |
| 16 | + |
| 17 | +3. Clicking on the *Flow* button exapnds to show you more options: |
| 18 | + |
| 19 | + * Create a flow |
| 20 | + * See your flows |
| 21 | + |
| 22 | + > **Note:** You may see other options as well such as 'Request sign-off' and other flows if they are available for the list or library here. |
| 23 | +
|
| 24 | +4. Click on *Create a flow*. |
| 25 | + |
| 26 | +5. In the *Create a flow* panel, you can explore various templates available for your list. |
| 27 | + |
| 28 | +6. Click on the template that reads: |
| 29 | + > Send a customized email when a new SharePoint list item is added. |
| 30 | +
|
| 31 | +7. This will take you to the Flow website where it will display more options: |
| 32 | + * Template information |
| 33 | + * Name and description of the template. |
| 34 | + * Connection information |
| 35 | + * Varioius services this flow connect to. |
| 36 | + * The credentials those services will use to connect to. |
| 37 | +8. Verify the connection information to ensure it uses your credentials. |
| 38 | + > A green checkmark icon indicates a connection to the service was succesfully made using your credentials. |
| 39 | +
|
| 40 | +9. Click *Continue* to create the flow. Any connections that requires a connection will also be attempted during this step. |
| 41 | + |
| 42 | +10. Once the flow is created successfully, you will be redirected to the flow designer where you can edit and modifify the flow if needed. |
| 43 | + |
| 44 | +11. Click on the name of the flow that reads *Send a customized email when a new SharePoint list item is added* and enter the following name for the flow: |
| 45 | + * Send an email for new projects |
| 46 | + |
| 47 | +12. The SharePoint actions are represented with the SharePoint logo in the flow designer. |
| 48 | + |
| 49 | +13. In the *When the new item is created* action, click on *Edit* to expand the action. |
| 50 | + |
| 51 | +14. Notice the input configured to the SharePoint site address and list name fromk where you created the flow. |
| 52 | + |
| 53 | +15. In the *Send Email* action, click on *Edit* to expand the action. |
| 54 | + |
| 55 | +16. Notice all the input is filled in with dynamic values from the *Get my profile* and *When the new item is created* actions. |
| 56 | + |
| 57 | +17. Hover over the dynamic values to see what properties they refer. For example, hovering over the *Email* shows that the property is read from the *Get my profile*'s *Mail* property. |
| 58 | + |
| 59 | +18. Click *Save* to save the flow. |
| 60 | + |
| 61 | +Your flow is active as soon as you save the flow. In our case, this flow *Send an email for new projects* is now active and will run whenever new items are added to the *Projects* list in the specified SharePoint site. |
| 62 | + |
| 63 | +## Test your flow |
| 64 | + |
| 65 | +In order to test your flow, you can test it by adding a new item in SharePoint list by adding a new item or initiating the test run directly from the flow designer. Follow the steps below to test the flow from the designer. Testing the flow from the designer helps you to quickly see the flow run as the flow is executed. |
| 66 | + |
| 67 | +1. In the flow designer, click on *Test* on the top command bar. |
| 68 | + |
| 69 | +2. In the *Test Flow* panel, click on *I'll perform the trigger action* and then click on *Save & Test* button. |
| 70 | + |
| 71 | +3. You should see a message that instructs to add a new list item to the SharePoint list you selected. |
| 72 | + |
| 73 | +4. You should have the browser tab with the *Projects* list opened already. If not, open a new browser tab and browse to the *Projects* list. |
| 74 | + > Do not close the flow designer. Make sure you keep the flow designer browser tab open. |
| 75 | +
|
| 76 | +5. In the *Projects* list, click on the *New* button on the command bar, add the item as specified below and click *Save*: |
| 77 | + * Title: Project 4 |
| 78 | + * Owner: pick a user from people picker |
| 79 | + |
| 80 | +6. Switch to the flow designer tab. |
| 81 | + |
| 82 | +7. You should see the flow run history. If all of the actions were executed successfully, you will a green checkmark icon besides every action. |
| 83 | + |
| 84 | +8. You can also click on the action to see the inputs and outputs used in the flow run. This is also a good place to see the actual values translated from those dynamic content properties used in that action. |
| 85 | + |
| 86 | +9. As a result of this flow, you should have received an email as well regarding the new project information. |
| 87 | + |
| 88 | +## Modify your flow |
| 89 | + |
| 90 | +1. In the flow designer, click *Edit* to edit your flow. |
| 91 | + |
| 92 | +2. Click on the *Send Email* action. |
| 93 | + |
| 94 | +3. In the *Body* input, append the following string after the *Name* dynamic property: |
| 95 | + * Owner: |
| 96 | + |
| 97 | +4. While you are still editing the *Body* input, notice the *dynamic content* list that appears beside the action. |
| 98 | + |
| 99 | +5. In the *dynamic content* list, you can pick values from the actions in your flow. For example: The project owner information is available in the *When the new item is created* trigger. |
| 100 | + |
| 101 | +6. To add the owner information, search for *owner* in the search box in the *dynamic content* list. |
| 102 | + |
| 103 | +7. In the results, click on *Owner DisplayName*. As you can see, it also displays other information such as email, job title, picture and more. Since the *Owner* is a person column in SharePoint, SharePoint passes along the person details as individual properties to the flow. |
| 104 | + |
| 105 | +8. The modified *Body* input should now look like this with the included *Owner* information. |
| 106 | + |
| 107 | +9. Repeat the steps to test the flow. |
| 108 | + |
| 109 | +10. You should now get an email with the updated owner information in it. |
| 110 | + |
| 111 | +## Next steps |
| 112 | + |
| 113 | +Congratulations on creating your first flow! |
| 114 | + |
| 115 | +In the next topic, we will use the same flow and add the ability to interact with Microsoft Teams. |
0 commit comments