[The following content is deprecated – please read the new version]
This article describes how to send an email to users enrolled in self-paced training using the SharePoint|sapiens Employee Training Management app for Office 365.
The Employee Training Management automatically sends emails invitations if users enroll in scheduled training events. If you also want to send notifications if users enroll in self-paced training, either directly or via a curriculum, you have to create your own flow using Power Automate. The advantage of Power Automate is that you can create automated workflows with a great flexibility, you decide when to send a notification, what information you want to include, whether you want to send recurring reminders, etc.
In this example I want to send a notification as soon as a user enrolls in a course based on the content type ‘Self-paced training’ or ‘Online exam’. In the email notification I want to include the course title, the course description and a link to the course page, if one exists (Learn more about course pages). I also want to include a link to the ‘For learners’ landing page so that users can take a look at their learner profile and check if other courses are still due and if there are any upcoming events they have to attend.
In the workflow I also want to check weekly if the course has been completed. If not, I want to send another reminder. Once the course has been completed, I want to terminate the workflow.
Create the flow using Power Automate
To make it easier for you to use this flow, I created a flow template that you can use to create the flow.
To import the flow template, open Power Automate https://flow.microsoft.com/, select My flows, and click on Import.
Select the downloaded ZIP package and click on Import.
What you can see now is that the Flow has been configured in a demo environment. That’s why you first have to change the resource connections. Click on Select during import in the IMPORT SETUP column and create a connection to Office 365 Outlook and SharePoint.
Now click on Import. Once the workflow is imported, click on Open flow at the top.
This flow starts with a When an item is created trigger.
What trigger to we need?
If users enroll in a course, the following two items will be created in SharePoint:
- A new item will be created in the list Enrollments in Courses or Exams
- A new item will be created in the list Achievements
This means that the workflow should start when an item is created in one of these two list. My recommendation is to use the Achievement list, since the achievement also contains the information if the user has already completed the course.
Select the SharePoint site where the Employee Training Management app is configured and select the list Achievements, click on Show advanced options and select one of the available views.
The view can be used to avoid column threshold issues by only using columns defined in this view. My recommendation is to use the view My Achievements.
You also have to update the variables in the next 3 steps:
- SiteUrl: Enter the URL to your SharePoint Site. E.g. https://company.sharepoint.com/sites/training
- ServerRelativeUrl: Enter the server relative Url to your website. Make sure the Url ends with /. E.g. /sites/training/
- SharedMailbox: Enter the email address of the shared mailbox you want to use to send the notification. E.g. [email protected]
Please note that we use the action Send an email from a shared mailbox (V2) later in the workflow. If you want to send the email from your mailbox or from another account, please use Send an email instead and make sure the connection is correct. In this case you don’t need the SharedMailbox variable.
The trigger and the 3 variables are the only actions you have to modify after importing the template. Save the flow, click on Test/I’ll perform the trigger action an enroll yourself in a self-paced training in the Employee Training Management SharePoint site to test the flow.
Below I would like to explain the rest of the workflow in detail in case you want to change the email notification or the logic in general.
Get action Send Http Request to SharePoint: Get recipient is used to get the email address of the enrolled user. For this we use the following GET request using the SharePoint REST api.
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensAchievementsETM')/items([Trigger:ID])?$select=EMail
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensAchievementsETM')/items([Trigger:ID])?$select=EMail
This will get the item value of the EMail address column in the Achievement list. The result will be stored in the next variable Recipient.
body('Send_Http_Request_to_SharePoint:_Get_recipient')['d']['EMail']
body('Send_Http_Request_to_SharePoint:_Get_recipient')['d']['EMail']
The next 5 variables will only be initialized, we’ll set the value later.
Get action Send Http Request to SharePoint: Get ContentTypeId is used to get the ContentTypeId of the course selected. For this we use the following GET request using the SharePoint REST api.
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensCatalogETM')/items([Trigger:evmLookupTopicsID])?$select=ContentTypeId
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensCatalogETM')/items([Trigger:evmLookupTopicsID])?$select=ContentTypeId
We need the result in the next condition to make sure the user is enrolled in a self-paced training. We can get the result using the following expression:
body('Send_Http_Request_to_SharePoint:_Get_ContentTypeId')['d']['ContentTypeId']
body('Send_Http_Request_to_SharePoint:_Get_ContentTypeId')['d']['ContentTypeId']
In the condition we make sure that the ContentTypeId start with the following Id:
0x0100D1D8BE663150441DB3D0EEC0EF9DAF3F00514A447C32984522818D3B722FB1382F
0x0100D1D8BE663150441DB3D0EEC0EF9DAF3F00514A447C32984522818D3B722FB1382F
This condition will be true for enrollments in Self-paced training or Online Exams and any content types you inherit on one of these content types.
In the If yes clause we start with a Do until that runs until the variable CourseCompleted is equal to true. We use this to send multiple email notifications until the user completes the course.
In the Do until clause we start with getting the course title, description and course page link. We do this in each cycle, to get the latest title, description or course page in case it changed in the meantime.
For the action Send Http Request to SharePoint: Get title, description and course page link we use the following GET request using the SharePoint REST api.
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensCatalogETM')/items([Trigger:evmLookupTopicsID])?$select=Title,evmDetailsPageLink,evmDescription
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensCatalogETM')/items([Trigger:evmLookupTopicsID])?$select=Title,evmDetailsPageLink,evmDescription
The result will be stored in the next 3 variables
Title:
body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['Title']
body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['Title']
Description:
body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['evmDescription']
body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['evmDescription']
CoursePageLink:
If(not(empty(body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['evmDetailsPageLink'])), body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['evmDetailsPageLink']['Url'],'')
If(not(empty(body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['evmDetailsPageLink'])), body('Send_Http_Request_to_SharePoint:_Get_title,_description_and_couse_page_link')['d']['evmDetailsPageLink']['Url'],'')
Here we use an if not empty condition to make sure a course page has been created for this self paced-training. Learn more about course pages
Next we use the action Send an email from a shared mailbox (V2) to send out the notification. As mentioned above if you want to send the email from your mailbox or from another account, please use Send an email instead and make sure the connection is correct. You can also change the mail subject and body.
Next we use a Delay action to pause for 7 days.
Next we want to check if the course has been completed in the meantime. If the course has been competed, the Course Completed variable will be set to true and this will complete the workflow, since the Do until condition is set to …until CourseCompleted is equal to true.
For the action Send Http Request to SharePoint: Get achieved we use the following GET request using the SharePoint REST api.
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensAchievementsETM')/items([Trigger:ID])?$select=etmAchieved
_api/web/GetList('[Variable:ServerRelativeUrl]Lists/sapiensAchievementsETM')/items([Trigger:ID])?$select=etmAchieved
The result will be stored in the next variable:
If(equals([body('Send_Http_Request_to_SharePoint:_Get_achieved')['d']['etmAchieved'],true),true,false)
If(equals([body('Send_Http_Request_to_SharePoint:_Get_achieved')['d']['etmAchieved'],true),true,false)
Finally, we increate the variable ReminderNo. We use this to add the number of reminders sent to the email subject.
I hope you found this guide useful. If you have any questions, please send an e-mail to [email protected].