Business Process Creation
Practice in creating business processes
It's time to put it to the test. Let's move on to the section on working with business processes. Let's create the first business process and set up the internal logic of its work.
By clicking on “+ Create business process”, a modal window will open with parameters for creating a new business process:
- Process name. The only required field.
- Folder. If there are a lot of business processes, then it is more convenient to break them into groups and place them in the appropriate folders.
- Description. One name may not be enough to fully convey the purpose of the BP and reveal the details of its work. The description field is intended for such information.
- Transaction mode. If the switch is activated, the BP acquires the property of atomicity. This means that the BP is either fully executed, or none of its individual blocks are executed. If an error occurs in any block, then all changes caused by previous blocks will be rolled back.
Let's create a business process that receives the values of two numbers as input. Let's perform mathematical operations with these numbers. Let's calculate the results of:
The result of the division we’ll also additionally round up to the first decimal place.
As a result, we will have to get 5 numbers, which we will combine into an array. It is this array that will become the result of the business process.
It all starts with input. It is necessary to determine the numbers with which we will carry out mathematical operations. It is important to understand that we are not asking numbers as such. We create variables that take on the required values. This can be compared to solving school equations. X + Y = Z. So we will not set specific 2 numbers, but abstract X and Y. In the future, their exact value can be set by anyone.
To set the input values, select the Start block. A section for setting variables will appear in the right pane. It is necessary to set their names (we have already decided that they will be X and Y) and select the type of variables. In the second module, we discussed that there are two options available for writing numbers. Integer (for integer data) and Float (for floating point numbers). In this case, we are not going to be limited to integer values, so it will be correct to choose the Float type.
The next step is to add blocks of mathematical operations. They are located on the left panel and divided into sections. You just need to select the necessary ones and drag them to the workspace. First of all, we are interested in mathematical operations, respectively, we need the Sum, Subtract, Multiply and Divide blocks.
You can make sure that each block is a business process in miniature. It necessarily has a beginning (In) and an end (Out), as well as input and output data (most often they are there, but this is not mandatory, there are BPs without them).
The operations will be performed sequentially, one after the other. It is necessary to establish their connection (determine the order of their execution) and submit the necessary input data).
The next step is to round the division result. We use the Round block (Round Up or Round Down options are possible for rounding up and down, respectively), we feed the result from the division block as input and set the accuracy. We are interested in 1 decimal place, so we set the Precision parameter to 1.
The intermediate result should be something like this:
It is worth noting that the arrangement of blocks itself can be any. You can line them up in a row, you can place one block under another. This affects only the convenience of perception, but not the result of the business process. The main thing is that the communication lines themselves are set in the correct order, and the necessary data is received at the input of the blocks.
The next step is to create an array with the received data. The Append Array block is ideal for this. Its task is precisely to add a new element to the array. The input is an array and the required element, the output is an array with 1 more element.
Note that there is no need to manually set the data type. The block will automatically adjust to the required type, depending on what data it receives as input. If you apply Float to the input, then the output will automatically be an array of Float, it will not be possible to accidentally connect it to an incompatible data type.
We are adding 5 values to the array, so the Append Array block must be used 5 times. In the first case, it is sufficient to supply only the element to be added as input. The array will be created automatically. In subsequent cases, both the element and the array itself, to which we add the element, must get to the input.
By the way, in the left panel, next to Append Array, you can see functions with similar names. Prepend Array makes the new element the very first, and this is different from Append, which adds an element to the end of the array. The Concat Array block is used to concatenate two arrays.
AppMaster uses many different blocks. Do not be afraid to experiment and use them all, even if there was no information about a specific block within the course.
To transfer the final result, it remains only to add the corresponding variable to the End block. In our case, this is a Float Array.
The creation of the first business process is finished! In the next module, we will understand how to use it in practice, supply input data and receive a result.