This how-to is based on the video “Build a simple HRM app: Smarten up your app with business logic”, which is part of the Getting Started videos.
This is the last how-to in a series of five on how to create a simple HRM application. In this how-to you learn how to smarten up your application by adding business logic.
After completing this how-to you will know:
- How to create a microflow.
- How to build business logic.
Before you can start with this how-to, make sure you have completed the following prerequisites.
2. Create a microflow
In this chapter you will create a microflow.
2.1 Add an action button that calls a microflow
- Open the Employee_Overview page of the MyFirstModule module.
- Right-click on the grid control bar of the data grid in the master detail container.
- Click on Add button > Action. Click here to learn more about an action button.
- Double-click on the new button.
- Change the caption of the new button to Promote.
- Select Call a microflow as on click event. Click here to learn more about a microflow.
- Click on Select to select a microflow.
- Click on the MyFirstModule module.
- Click on New to add a new microflow to the Responsive module.
- Enter _EmployeePromote in the Name field.
- Click OK to create the microflow.
- Click OK.
- Right-click on the new button.
- Click on Go to microflow.
The microflow should look like the image below:
2.2 Add an exclusive split
- Select an exclusive split from the toolbar of the microflow editor. Click here to learn more about an exclusive split.
- Click on the line to add the exclusive split to the flow.
- Double-click the new exclusive split to open the properties editor.
- Enter _Level?_ in the caption field.
- Press CTRL + SPACE in the expression field to display suggestions. Click here to learn more about microflow expressions.
- Select $Employee (MyFirstModule.Employee). This employee object corresponds with the input object of the microflow.
- Add a / (forward slash) to the value in the expression field. This will show all the attributes of the employee object.
Select Level (Enumeration ‘Level’).
Click OK. The exclusive split will now evaluate values from the Level attribute.
Double click on the line between the exclusive split and the end event.
Select Junior in the Value dropdown.
Click OK. When the Employee in the input parameter has the Junior level, this path will be executed.
Select an end event from the toolbar of the microflow editor. Click here to learn more about an end event.
Add the end event to the flow.
Drag a line from the exclusive split to the new end event.
Double click on the line between the exclusive split and the new end event.
Select Medior in the Value dropdown.
Repeat steps 27 through 32 for the Value Senior and (empty). The microflow should look like the image below:
2.3 Add activities to the microflow
Drag a Change object activity from the Toolbox to the Junior path. Click here to learn more about activities.
Double-click on the new Change object activity to open the properties editor.
Select Employee (MyFirstModule.Employee) in the input variable dropdown.
Set Commit to Yes. This will save the change to the database.
Set Refresh in client to Yes. This will update the value in the user interface.
Click on New to add a new change item.
Select Level (Enumeration ‘Level’) in the Member dropdown.
Click on Generate.
Select Medior in the Constant dropdown.
Click OK to save the change object properties. The microflow will look like the image below:
Repeat steps 1 through 12 for the Medior path. Make sure that you set the level value to Senior. The microflow should look like the image below:
Drag a Show message activity from the Toolbox to the Senior path.
Double-click on the Show message activity to open the properties editor.
Enter _Employee is already at senior level_in the Template field.
Drag a Change object activity from the Toolbox to the path which will be executed when the Employee has no level.
Repeat steps 2 through 12 for this new Change object activity and make sure that you set the level value to Junior. The microflow will look like the image below:
3. View your app
- Click on Run in Sandbox.
- Click on the Save and continue button.
- Click on View App.
- Click on Employees in the navigation list.
- Select an employee with level Medior.
- Click on PROMOTE. The level of the employee will change from Medior to Senior.
- Click on PROMOTE. You will see a message that you can not promote the employee because the employee is already Senior.
4. Related content
- Build a simple HRM app 1: Create, manage and deploy the app
- Build a simple HRM app 2: First steps in building a rich GUI
- Build a simple HRM app 3: Show related data in the GUI
- Build a simple HRM app 4: Enrich the GUI with Filter Options
Learn more about this topic using the following helpful links: