In this article we are going to see the flow configuration that will take care of creating a resource access approval in the event that an “Access Management” type ticket is opened.
For this tutorial, suppose that the environment has a type of “Access Management” service, already configured.
Suppose that this flow requires 2 stages of approval: in the first phase it will be up to the assignee group of the ticket to authorize access to the resource, in the second phase it will be a Deepser administrator user to authorize access to the resource.
The internships that we are going to create will be the following:
- Approval Of assignee Group
- User Administrator Approval
To configure a Stage Set it will be necessary to go to the Flow à Stage Set menu.
At this point we must click on the “Add Stage Set” button, then we will have to set in the Name field “Approvation Stage Set” and then click on “Save” or “Apply“.
At this point it will be possible to include in this stage set just created the various stages necessary, to do so you will need to click on Add Template:
Now in the screen that will open it will be possible to configure the new stage, for the purposes of this guide we can only configure the “Name” field and click on the “Save And New” button.
We will have to repeat this step for each stage we want to add.
For more information about stage sets and internships, please consult the page dedicated to Stage Sets by clicking on this link.
Once you have finished adding the stages we can go and click on the “X” button located in the upper right corner of the screen.
Configuring a Flow with Multiple Stages
Below we will report the final result of the flow:
To do this you will need to go to the Flow à Designer menu.
Now you will need to click the NEW button in the upper left corner of the page:
And then on the word “Flow” that will appear below the button.
At this point the following page will open:
Below are the fields with their meaning:
- Name, in this field we are going to define the name that this flow will have.
- Description, in this field we are going to define the description that will have the flow
- Icon, in this field we are going to define the icon that will have the flow
- Enable Log, this toggle if set to you will enable the log in the flow.
Once you have configured the fields mentioned above you will need to click on the “Save” button.
Now the following screen will appear:
At this point we are going to configure the “Trigger” field as follows:
Now you will need to click on “Save” to save the block.
Before continuing the configuration of the flow, it will be necessary to import the stages created in the previous point of this guide, to do so we will have to click on the three dots placed in the upper right part of the page.
In the screen that will open you will need to select from the drop-down menu the Stage Set to import and click on “Import“.
At this point, the stages set in the previous step of this guide will appear.
After clicking on the “Save” button, the stages will have been imported correctly.
At this point we will have to go and click on the button:
From the “Actions” section we are going to select a stage block that we will configure as follows:
Assignee Group Approval
At this point in the article, we are going to make a first big distinction that is, we will differentiate the case in which there is an assignee group in the ticket and the case in which there is not.
Next, we will have to insert an “If” block from the “Logic” section below the previous block, the if block will be configured in the following way to verify that the assignee group is set in the ticket.
Check if the Assignee group is not Present
In the left branch of the “IF” block we are going to configure an “Else” block, which will be present in the “Logic” section.
In the left branch we are going to insert an “End Flow” block.
Check if the Assignee group is Present
In the left branch we will insert a “Stage Error” block and an “End Flow” block, in the right one we will have to insert an “Ask for Approval” block, from the “Actions” section.
At this point we are going to configure the “Ask for Approval” block like this:
Check First Approval
At this point of the flow, we will insert an if block that will check if the approval has been accepted or if it has been rejected.
The if block will be configured as follows:
Below this IF we will have to go to configure in the left branch an Else block and in the right one instead, we will configure the procedure to continue the approval, as discussed in the following points of this article.
Else Branch Configuration:
In the left branch of the “if” block we will instead add an “Else” block, we will then insert a Stage block that will be configured in the following way:
Below the previous block we are going to insert an update record:
After this block, remember to insert an End Flow block.
IF Branch Configuration:
In the right branch of the “IF” block we will instead add a “Stage” block, which will be configured as follows:
Below the block a previous we are going to insert Script block that we will configure as follows:
In the “Expression (Script)” section we will insert the following code:
$usersCollection = Deep::getResourceModel('deep_admin/user_collection'); $usersCollection->getSelect()->join('admin_role', 'main_table.user_id = admin_role.user_id', ) ->join(['ar2' => 'admin_role'], 'ar2.role_id = admin_role.parent_id', array('user_type')); $usersCollection->addFilterToMap('user_id', 'main_table.user_id'); $usersCollection->addFieldToFilter('ar2.user_type', ['eq'=> 'ADMIN']); $this->setOutput('administrators', $usersCollection);
After the scripting block we must go to insert a new approval, through a “Ask for Approval” block, which will be configured as follows:
Check second approval status
At this point we will have to go to configure an if block that will allow us to check in which state the approval is.
To do this we will have to add under the previous block “Ask for Approval” a block “if” configured in the following way:
Below this if we will have to include in the right branch the case in which the approval was successful and in the left branch the case in which it was rejected.
Approved Accepted Branch Configuration
In the right branch we are going to figure a block “Stage” configured as follows:
Then we will insert a block “Update Record” which will take care of changing the status of the ticket that gave rise to the flow, to do this we will insert the following configuration in the update record block:
As a graphic precaution for users in this flow it was decided to set the “Error” status on the “Not approved” stage in case of approval.
To do this you will need to Add a Stage block configured as follows:
And then insert a “Stage Error” block, which does not require configurations.
Configuration branch Approval Rejected
In the left branch of the if block that controls the second approval, we are going to insert a Stage block configured as follows:
And finally, an “Update record” block to change the status of the ticket on which the flow is being executed:
Before you can see the effects of the flow you will need to enable the flow by setting the toggle “Status”.
At this point, the flow will be up and running.