Article published on the 11th of January, 2023.
WorkPoint Automate processes is a powerful tool to implement business logic in a wide range of scenarios. Especially when combining it with various endpoints which integrates to other systems or databases.
For example, being able to trigger Microsoft Power Automate flows from a WorkPoint Automate process is a way to implement complex business logic in your WorkPoint solution.
In this article, we will demonstrate how we can trigger a Microsoft Power Automate flow from a WorkPoint Automate process. We are going to send a user's e-mail address to the flow as a parameter, and the flow will return the user's manager from their Azure Active Directory profile. We can then use this manager in subsequent steps in the WorkPoint process, e.g., to set a "Responsible" field.
An example of how this process, or a similar process might work, is given in the following image:
Using the "Send Http Request", we can call an external endpoint, e.g., a REST service. In the case of our demonstration, we call a Microsoft Power Automate flow which returns us some information about the current user's manager profile.
This information is then stored in the context of the process from which we can use it is subsequent steps, such as an Entity form or a Create entity step.
2. Power Automate flow setup
An overview of the Power Automate flow used in this case is shown in the following image:
You can view an expanded version of the image below in the "Notes" section, where you can also find the exported flow.
We start the flow based on receiving an HTTP request. We then parse the parameters (the current user's e-mail address) coming from the request itself via the process.
Next, we initialize the site URL of our WorkPoint solution as a variable for later use.
We can then use the "Get manager (V2)" action in order to get information about the manager of the current user. We do this because we need to user principal name of the manager in the next action.
In the next action, the "Get user profile (V2)" action, we use the user principal name of the current user's manager to get the data from the manager's user profile. This data includes the manager's name, job title, department, e-mail, and a lot of other data.
In the process we are going to set up in WorkPoint, we also need some additional data from a hidden list on the WorkPoint solution, the "User Information List". To get this information, we make a HTTP request to SharePoint.
The data received from the HTTP request to SharePoint is then parsed, and we use a "Compose" action to combine the data from the manager's user profile with the data about the manager coming from the hidden SharePoint list.
As a final step of the flow, we respond tot he original HTTP request from the process with the combined data.
3. HTTP endpoint setup
Before we can use the "Send HTTP request" step in our WorkPoint process, we need to configure the endpoint we want to call in the HTTP endpoint library in WorkPoint.
This HTTP endpoint is set up in the following way:
- We title the HTTP endpoint configuration "Get user's manager".
- In the "Parameters" section, we add a single parameter called "user". We will use this parameter to send the e-mail of the current user to the endpoint using a POST request.
- In the "Url" field, we insert the URL of the endpoint we want to call. In this instance, the URL is given to us by the "When a HTTP request is received" action inside our Microsoft Power Automate flow, as shown in the following image:
- In the "Http(s) endpoint action" field, we select "POST".
- In the "Body" section, we construct a JSON object with a single key-value pair:
"CurrentUser" : [user]
This creates the key "CurrentUser" and links it to the "user" parameter we created earlier. By doing this, we can insert an e-mail address into the "user" parameter, and it will be sent along to the Power Automate flow. This is needed in the "Send HTTP request" step in the WorkPoint process.
4. WorkPoint Automate process setup
In this section we will describe how we use the Power Automate flow in our WorkPoint Automate process.
- We create a new process from scratch, which we title "Create project". We select "User Process".
The first step in our process is a "Send HTTP request" step:
We configure the "Send HTTP request" step options as follows:
- In the "Endpoint (from endpoint library)" field, we select the "Get user's manager" endpoint we set up earlier.
- The "Get user's manager" endpoint has 1 parameter; the "user" parameter. As we remember, the "user" parameter is meant to take an e-mail address and send it with the HTTP request to the Power Automate flow. In this case, we select the current user's e-mail address from the context. This ensures that whomever runs this process, their e-mail address will be sent to the flow, and their manager will be returned.
We also make a quick note that the "Name" of this step is "CustomEndpointExecution":
The next step we add to the process is an Entity form:
We configure the options for the Entity form as follows:
In the "Fields" tab, we make some configurations as well:
- In the "Value" property of the "Project manager" field, we assign the entire CustomEndpointExecution object. This object contains all information returned by the endpoint we call in the first step, and the system will insert the whose information is returned, i.e., the current user's manager.
- In the "Project assistant" field, we assign the CurrentUser object from the context in the Value property. This will insert the user who is running the process to the "Project assistant" field.
- As a last example, we have a text field on Projects as well called "Department". In this field, we assign the "Department" value from the data returned by the endpoint, to the "Value" property. This will take the department of the user's manager, and add it to the "Department" field on the project.
Next, we add a "Create entity" step to the process:
In the "General" tab, we set the following settings:
- In "Step Input" we select the output from the Entity form.
In the "Options" tab, we set the following settings:
Note that the "Stage" value is set to "Entity.ContentTypeId".
We can now save and publish, and try to run the process:
- After the "Send HTTP request" step has run and the Entity form is displayed, we can see that the flow has correctly returned the current user's manager (Lars Radoor), and also added the current user to the "Project assistant" field.
- Additionally, the manager's department has been added to the Department field.
If we fill in the rest of the project meta data, and continue to the next step in the process, it will create a new entity in our Projects business module:
5.1. Power Automate Flow
The following image shows the Power Automate flow used for the case in this article with all actions expanded:
Download the Get User Manager Profile flow here:
Remember to insert your WorkPoint solution URL in the "Initialize Site URL" action.
Please also note that this is an example flow - it might not work for your specific case.