Good day to all! Today I'd like to share a small example of automating the process of creating new employee requests using Microsoft SharePoint products, PowerApps, Power Automate and Teams. This process does not require the purchase of separate PowerApps and Power Automate user plans, an Office365 E1/E3/E5 subscription will suffice. On the SharePoint site, we will create lists and columns, PowerApps will help to make a form, and Power Automate will provide opportunities for customizing business process logic. We will connect the final process to the MS Teams team. Let's not waste time and see what happens.
At the first stage, we create lists and details. We need lists:
- Employee leave requests
- unit
- HR by departments
- Administrators
Each list will play its role in the future, and we will see which one. Create props and set up the navigation menu:
Power Apps
Now, let's make a form for the "Employee Leave Applications" list using PowerApps. In the final form, it will look like this:
In the "Employee" field, a selection is made from the list of Office 365 users, "Exit Date" is indicated from the calendar, "Department" is indicated from the directory of departments, and "HR" is selected from the directory "HR by departments":
But it is necessary to make sure that the list of HR available for selection is filtered by the unit indicated on the form. Let's use a formula to filter data in PowerApps. For the "Items" property of the "HR" field, write:
Additionally, you can make small adjustments to the default value of the Status field on the form. For the "Default" property of the "Status" field, write:
If the item creation form is opened, then the value "New" will be written in the "Status" field, otherwise, the value from the SharePoint column for the current item will be substituted into the status field on the form.
One of the problems with PowerApps is the inability to easily retrieve data from SharePoint groups. In this regard, it is not possible to easily configure the visibility / availability of fields or objects on the form if you wanted to get involved in the user's entry into the SharePoint group. But you can make a workaround. Especially for this, we have previously created a list of Administrators:
This list contains an "Employee" field with the "User or Group" type, displayed only on the form, and a "Name" field in which the name of the selected employee is written, displayed only in the list view. Now, let's do a little trick in PowerApps. For example, you can set the availability of any field to the condition that the current user is in the Administrators list. Find the "Display Mode" property of the "Release Date" field and write:
According to this formula, if there is at least one employee in the Administrators list whose login matches the login of the current user, then the field will be available for editing, otherwise, for viewing. For greater reliability, we bring the login to lower case, otherwise there are all sorts of cases.
You may have noticed that in the form header there is a button "Actions on the application":
This button will switch to another screen, where, for convenience, all possible actions on the application are collected:
After clicking on each button, an additional window of actions opens, for example, if the action βCancel orderβ is selected, then an additional window opens with the ability to enter a comment:
After clicking on the "Confirm" button, the status of the application changes, and this can be done even without starting the Power Automate flow. Let's use the "Patch" function for the "OnSelect" property of the button:
Using the Patch function, we update an element in the list of requests by filtering it by the ID of the current element. We change the value of the "Status" field and make the transition to the main screen. For other action buttons, the logic is similar.
It remains to configure the approval flow. Let's do it in its simplest form.
Power automat
Our approval flow will be launched automatically when an application is created. During execution, the status of the application will change, the head of the unit will be received and an email notification about the new application will be sent to the head. To determine the head, we have a reference book "Subdivisions":
Create a Power Automate flow:
During the execution of this flow, the head of the department receives an email notification about the creation of a new application and can follow the link to make a decision by clicking on the button:
Clicking the "Approve" or "Reject" button also launches the Power Automate flow, which changes the status of the application and sends an email notification to the HR specialist:
The process is ready.
teams
And the final touch is the organization of joint work with this process. To do this, we connect the process to the MS Teams team:
Now, all members of the MS Teams team have access to the process of leaving new employees on a separate tab.
Of course, you can provide multi-step approval in your flow logic, plus you can use the Approvals component to assign Power Automate tasks. You can also set up reports and generate notifications that will be sent to the Microsoft Teams chatbot. But more on that in future articles. Thank you for your attention and have a great day!
Source: habr.com