Creating Fulfillment Workflows
This tutorial guides you through the process of creating a fulfillment workflow that manages the deletion of multiple accounts. The workflow receives a list of Business Request Items, performs the deletion operation on each, and includes logic to verify if there are any accounts to delete using line rules.
This documentation offers comprehensive guidance on developing fulfillment workflows using Workflow Studio. For an overview and foundational concepts of fulfillment workflows, see Overview of Fulfillment Workflows.
What You'll Learn
In this tutorial, you will:
- Use the fulfillment workflow template in Workflow Studio
- Understand the default activities in the fulfillment template
- Add code to delete multiple accounts
- Configure skip rules to optimize workflow execution
- Enable operations within the workflow
- Link the fulfillment workflow to Item Type Actions
- Compile and publish the fulfillment workflow
Prerequisites
This tutorial assumes you are familiar with basic Workflow Studio navigation, C# programming, and EmpowerID Business Request concepts. You should understand how operations work in workflows.
Create Fulfillment Workflow
In this example, the goal is to create a fulfillment workflow that can handle deleting all input accounts. Follow the instructions below to develop the 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:
- 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 in both activities:
- Click on the Set Operation Inputs activity and modify the code to set the workflow name correctly.

- Click on the SetBusinessRequestItemStatus activity and repeat the same process.

- Click on the Set Operation Inputs activity and modify the code to set the workflow name correctly.
-
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 the following 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;
} -
Add the following 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); -
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 Create New button.
-
Click on Add after providing a suitable name to save the rule. Click Close to return to the previous window.

-
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:
return CurrentWorkflow.DeleteAccounts.TargetAccounts == null || CurrentWorkflow.DeleteAccounts.TargetAccounts.Count == 0;
Compile and Publish Workflow
- Click the Compile and Publish button in the Workflow Studio toolbar.
- In the Publish Workflow wizard that appears, click the Next button.
- Select the host server and click Next.
- Click Next again to begin compiling the workflow. Upon a successful compilation, Workflow Studio publishes the workflow.
- Select Yes when prompted to restart one or more services.
- In the Active Services window that appears, make sure the EmpowerID Web Role Service is selected and click Restart.
- Click No when prompted to restart Workflow Studio.
Link Fulfillment Workflow to 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 configure an existing Item Type action.
