Step 3: Add the ApproveDiscount Action
By using Workflow API, you can define actions without implementing them in a graph. You do
this by calling the ActionDefinitions.CreateNew method and specifying all
settings of the action, including the display name and category. This approach can be used
only if the action does not have complex logic. In this step, you will define the
approveDiscount
action without implementing it in a graph.
To add the approveDiscount
action, do the following:
- In the
SOInvoiceOrder_Workflow
class, define a string constant whose value will be used as the display name for theapproveDiscount
action, as the following code shows.public const string ApproveDiscount = "Approve Discount";
- In the Configure method of the
SOInvoiceOrder_Workflow
class, add the following code.var approveDiscount = context.ActionDefinitions .CreateNew(ApproveDiscount, a => a .DisplayName("Approve Discount"));
In the code above, you have defined a new action with the Approve Discount display name.
- In the WithActions method of the
UpdateScreenConfigurationFor method call, add the
approveDiscount
action, as the following code shows.actions.Add(approveDiscount);