Skip to end of banner
Go to start of banner

Fullfillment Workflows

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

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 guide provides developers with a comprehensive understanding of creating and implementing fulfillment workflows by providing a sample workflow.

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.

FullFillmentWF-Page-2.jpg

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.

FullFillmentWF-Page-1-20240314-130845.jpg

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

In this example, our goal is to create a fulfillment workflow that can handle the deletion of all input accounts. Follow the instructions below to develop the workflow.

  1. 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.

    EmpowerID.BPM.Studio_zozCmfZxOr.png

  2. 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.

      image-20240313-095434.png

  3. 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.

    image-20240313-095940.png

  4. 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.

    image-20240313-102657.png


    image-20240313-102616.png

  5. 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.

    image-20240313-105440.png

  6. Click on the newly added operation activity and provide a suitable name and description.

    image-20240313-105911.png

  7. Enabling an operation is important after adding it. Right-click on the operation and select Enable/Disable option.

  8. 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.

    image-20240313-112111.png

  9. Add some code to the Set Operation Inputs activity in the Implement Method.

    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;
    			}
    
  10. Add Code to the Implement Method of the SetBusinessRequestItemStatus activity.

    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);
  11. 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.

    image-20240313-135000.png


  12. To create a new rule, click on the Create New button.

  13. Click on Add after providing a suitable name to save the rule. Click Close to return to the previous window.

    image-20240313-135314.png

  14. Please choose the recently created rule from the dropdown and apply it to the operation.

    image-20240313-135834.png


  15. 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.

    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.

image-20240314-082135.png

  • No labels