Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Fulfillment workflows are a feature in EmpowerID that are designed to fulfill the actions to be taken once a business request item has been processed, and a decision has been made regarding the business request item. Depending on the decision made, the configured fulfillment workflow can be developed to execute actions such as provisioning, de-provisioning, disabling, deleting, or any other action that is necessary in response to the decision made in the business request item. The fulfillment workflows are designed to run in the background and provide status updates to the business request item to indicate whether the fulfillment has been completed or not.
This document provides developers with a comprehensive understanding of fulfillment workflows, including their purpose, functionality, and implementation.
Overview of Fulfillment Workflows
A Business Request can consist of multiple Business Request items in EmpowerID, each of which may have associated Item Type Actions. By linking the fulfillment workflow with these item-type actions, you enable the automated execution of workflow for fulfillment. By design, the fulfillment workflow is best suited for No Code Flows, although it can be triggered or executed from other EmpowerID workflows as well.
The role of Business Request Fulfillment is to process the business requests that are ready to be fulfilled. Each business request is associated with a specific Item Type Action, such as approval or rejection. The job of the Business Request Fulfillment is to identify the corresponding fulfillment workflow that is configured with the item type action and then initiate its execution to fulfill the actions accordingly.
The fulfillment workflow is designed to receive a list of business request items called TargetBusinessRequestItem. These items need to be fulfilled and to do that, the fulfillment workflow retrieves all relevant business request items and gathers the necessary data to execute the specified actions. Within the fulfillment workflow, the logic required to perform the desired actions or tasks on each item for the fulfillment is embedded. Once initiated, the fulfillment workflow operates autonomously in the background and executes the specified actions without requiring any manual intervention. The fulfillment workflow should update the business request item status to indicate the fulfillment status and show if all actions were executed successfully.
To give an example, let's say there's a business request that has multiple items, each with an item type action to delete or disable all associated accounts within the business request items. In such cases, the fulfillment workflow comes into play. We integrate the necessary logic into the fulfillment workflow to handle these scenarios seamlessly. When the fulfillment workflow kicks in, it locates all accounts associated with each business request item and then executes the deletion or disabling process.
Create a Fulfillment Workflow
Right-click on the Package node in the Workflow Studio and select New Workflow > Fulfillment Workflow from the context menu to create a new fulfillment workflow.
Upon creation, you will see the fulfillment workflow with the following default activities. Let me give you a brief summary of these activities:
ValidateClaimedBusinessRequestItems: This activity validates the business request items associated with incoming calls from consoles, APIs, etc. It retrieves data from the database to verify the business request items exist and their status. This activity also updates the Fulfillment Process ID for the business request item to indicate the business request that is currently fulfilling the business request item.
SetOperationInputs: This activity extracts the operation input parameters or the business request items against which the fulfillment has to be done.
Drag Operation Activities Here: This is a placeholder where you can drag and drop additional activities into the workflow.
SetBusinessRequestItemStatus: This activity sets the execution status of the business request items, indicating whether it was successful or not.
Save the workflow by clicking on the Save icon in the toolbar and provide a suitable name for the fulfillment workflow. Once you save, the workflow will reload and show you the default activities.
Ensure the workflow name is updated. Click on the Set Operation Inputs Activity and modify the code to set the workflow name correctly. Repeat the same process for SetBusinessRequestItemStatus Activity.
We will perform the delete account operation using the default operation available in EmpowerID. To find the necessary activity, go to the Activities pane, enter the relevant search text, and select the Delete Account Operation from the search results. Afterward, drag and drop the activity to the "Drag Operation Activities Here” placeholder.
Click on the newly added operation activity and provide a suitable name and description.
Enabling an operation is important after adding it. Right-click on the operation and select Enable/Disable option.
After selecting the Enable/Disable option, a popup will appear. Click on the forward arrow (>) to select. Once the desired operations are in the right pane, they are ready to be enabled.
Add some code to the Set Operation Inputs activity in the Implement Method.
Code Block List<Guid> targetAccountGuids = CurrentWorkflow.ValidateBRIs.ClaimedBusinessRequestItems.Select(a => a.RequestDataTargetResourceID.Value).Distinct().ToList(); E.TList<C.Account> targetAccounts = Account .GetByAccountGuids(targetAccountGuids); var nonDeletedAccounts=new E.TList<C.Account>(targetAccounts.Where(a => !a.Deleted).ToList()); CurrentWorkflow.DeleteAccounts.TargetAccounts=nonDeletedAccounts; CurrentWorkflow.BusinessRequestItemDictionary = new Dictionary<Guid, BusinessRequestItem>(); foreach (var bri in CurrentWorkflow.ValidateBRIs.ClaimedBusinessRequestItems) { if (!nonDeletedAccounts.Where(a=>a.AccountGUID==bri.RequestDataTargetResourceID.Value).Any()) { bri.ProcessStatus = 4; bri.BusinessRequestItemFulfillmentStatusID=4; } CurrentWorkflow.BusinessRequestItemDictionary[bri.RequestDataTargetResourceID.Value]=bri; }
Add Code to the Implement Method of the SetBusinessRequestItemStatus activity.
Code Block List<Framework.Common.Shared.Workflow.OperationExecutionSummary> oplist = CurrentWorkflow.DeleteAccounts.OperationsExecutionSummary; foreach (Framework.Common.Shared.Workflow.OperationExecutionSummary op in oplist) { var bri = CurrentWorkflow.BusinessRequestItemDictionary[op.TargetResourceGUID]; bri.ProcessStatus = 2; if (op.OperationExecuted) { bri.BusinessRequestItemFulfillmentStatusID = 3; //success } else { bri.BusinessRequestItemFulfillmentStatusID = 4; //Fail bri.ProcessStatus = 3; bri.FailedCount += 1; bri.LastFailed = DateTime.UtcNow; bri.NextAttempt = DateTime.UtcNow.AddMinutes(10 * bri.FailedCount * bri.FailedCount); bri.LastFailedError=op.ExecutionResultMessage; } } var businessRequestItems=new E.TList<C.BusinessRequestItem>(CurrentWorkflow.BusinessRequestItemDictionary.Select(a => a.Value).ToList()); BusinessRequestItem.Update(businessRequestItems);
If there are no accounts that need to be deleted, you can make the process more efficient by using a skip rule. This rule will ignore the execution of the added operation. To add a skip rule, simply right-click on the activity and choose Select Skip Rule.
To create a new rule, click on the Create New button.
Click on Add after providing a suitable name to save the rule. Click Close to return to the previous window.
Please choose the recently created rule from the dropdown and apply it to the operation.
Right-click on the operation activity and select Edit_{YourRuleName} from the context menu. Add the following code into the Evaluate method to include skip logic to the skip rule.
Code Block return CurrentWorkflow.DeleteAccounts.TargetAccounts==null||CurrentWorkflow.DeleteAccounts.TargetAccounts.Count==0;
Compile and Publish the Workflow
Before we can test the fulfillment workflow, the workflow needs to be published. Publish it to EmpowerID. For more information about it, find more details here.
Link Fulfillment Workflow to an Item Type Action
Once you've created a fulfillment workflow, it's crucial to set up its trigger mechanism. One typical approach is to link it with No Code Flows via Item Type Actions. This method ensures that whenever a certain Item Type action is chosen for a specific business request type, the corresponding configured workflow is automatically activated to perform the designated action.
You can create an Item Type action and select the fulfillment workflow that you created or configured for an existing Item Type action.
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
IN THIS ARTICLE
|