Editing data components
Executing actions conditionally
Using smart objects
Configuring a decision matrix
We have configured our work Stream to enable an employee to request a leave of absence with a digital application form. Right now that request is being sent to their manager even if the employee has not accrued a leave balance. Today we will introduce a check to reject a leave request if the employee has no leave days to use before their request is sent to their manager.
To do this we will need to calculate the total number of days requested. Let’s create a data field to store that information. Start by going to your Stream Definition Canvas and opening the Request data component. (Hover your mouse over it to reveal the edit function. Click on that.)
Go to the Field tab of the Edit Data Component configuration popup. Add a new field. Title it “Number of Days Requested.” This type of field will contain a “Number.” Select that in the pull-down menu. When you're done, your screen should look like this:
Save the field.
Add another field. Title it “Exceeds Accrual.” This type of field will contain “Boolean” information. Select that in the pull-down menu.
When you are done your screen should look like this:
Save the field. Save your changes to the Data Component.
Next we will modify the Setup Data step to include this data. From your Stream Definition Canvas, double click on the Setup Data step to open it. In the Update Data Fields configuration popup menu, click on the “add another field” text to add another field. The Map Type will be an “Expression,” so select that in the pull-down menu.
In the Value / Expression box we will use a function called diffDays to calculate the difference in days between the leave start date and end date. You can see all available functions by clicking on the “Help with Expressions” text above the Value/Expression fields.
Use the merge field value finder to find the appropriate values for the start date and the end date. This is accessed by clicking on the magnifying glass icon to the right of the field. Copy the merge field values and paste them into the box, entering them as parameters inside of the diffDays function. Eg diffDays(Request.End_Date,Request.Start_Date)
When you're done, your Update Data Fields configurations should look like this:
Save your changes to the step.
Next let’s modify our Calculate Due Date step. Double click on the step to open it. Here in the Execute Actions Conditionally configuration popup, let us first change the title of the step.
We will call it “Calculate Due Date and Check Balance.”
Add a new conditional execution by clicking on that text under the title field. We will build an expression to determine if the employee leave balance is less than the number of days requested. If that is the case, then the Exceeds Accrual value should be set to yes. For the condition, select “Expression” from the pull-down menu. Use the merge field value finder tool to get the merge field value for the employee’s leave balance. (Click on the magnifying glass icon to open that feature.)
With the Data Component tab in focus, find “Employee.” Click on it. That will make all the fields in the Smart Object available. In the subsequent popup, find the “Leave Accrued” field. Select that. Copy that value. Paste it into the expression box. Use the merge field value finder tool again to get the value for the Number of Days Requested. Select that. Copy it. Paste it into the box. Then use the less than operator to create a logical expression. Your expression should look like this: Request.Employee.Leave_Accrued < Request.Number_of_days_requested
The actions that we specify here will only be executed if this expression is true. t will be true only if the employee’s accrued leave balance is less than the number of days they requested. Next, add an Action that will update the fields. Select “Update Fields” in the first Action pull-down menu.
In the Field pull-down menu, select “Exceeds Accrual.” The Map Type will be “Literal.” The Value / Expression will be “Yes.” Save your changes to the step. When you are done your execution condition should look like this:
Save your changes to the step. Save your changes to the process. (The stream)
It’s time to rearrange the flow of the stream. Delete the connection line between the Calculate Due Date and Check Balance Step and the Review Application step.
In your Stream Definition options menu, find the gateways.
Get a Decision gateway and drag it onto your canvas.
In the Decision Matrix configuration popup, title this “Accrual Exceeded Check.” We will use conditional columns here. Click “Edit Conditional Columns.” Add one to create an if __ condition.
To the right of the if statement that populates in the Decision Matrix configuration popup, select “yes” from the pull-down menu. Click on the “Add Results” text to add 2 possible outcomes. The decision results will be “Proceed” and “Reject.”
Configure it so that if Exceeds Accrual is “yes,” the result should be “Reject.” Else, the result should be “Proceed.” When you are done, your screen should look like this:
Save our changes to the Decision Matrix. Back on the Stream Definition Canvas, connect the Calculate Due Date step to the Decision gateway. Connect the gateway to the “Review Application” step when the result is “Proceed.” Next, move the Fix Leave Request task up and reshape the stream flow to make it look neater.
Now if the leave accrual balance contains less than the number of days of leave that were requested, the application will be rejected. If not, then it will proceed through the stream. Success!
But wait. How would an employee know if their leave request application was rejected? An email template can handle this scenario. Let’s take some time to create an email template that will be used in the scenario that the employee does not have enough leave accrued to take the amount of days off that they requested. Call it “Lack of Leave Balance Notification.”
Remember that email templates are in your Components Catalog. Hover your mouse over the words "Email Templates" to reveal the "new" function. Click on that to create an email template that looks like this:
Personalize it to suit your culture. Simply make sure the name is the one that is in this image, because we will be referring to this name later. After you've created it, use the email template in an email step in between the Decision Gateway and the Fix Leave Request Task. Use this step to send the email to the leave request submitter. Your stream should look like this:
That takes care of that wrinkle. But there is one final wrinkle that requires ironing. When the accrued leave balance is not enough to fulfill the leave request, we had set the “Exceeds Accrual” flag to “yes.” However, what happens when the employee fixes the request?
When the balance is enough, this step would not get executed, but the flag would remain “yes.” So if the employee fixes the request and resubmits the application, since the flag remains set to “yes,” the application would get rejected again. To solve this problem, we should reset the flag to “no” every time it passes through the Setup Data Step. Let’s edit the Setup Data step. Double click it to open it. In the “Exceeds Accrual” row set the Value/Expression to “no.”
That’s it. Save the flow. Take it for a test run if you like.