Begin relevant processing in your application only under specified conditions by creating a circumstance definition. When you implement circumstancing in your application, you provide flexible solutions without defining complex logic. As a result, you increase efficiency and design an application that is easier to maintain in the future if your business requirements change.For example, in a banking application, if your circumstance template includes a LoanAmount property, and the definition includes the value 5000 with an operator >, the application resolves the circumstance rule only when the loan request amount is greater than 5000.
In the header of Dev Studio, click.
On the Create Circumstance Definition form, enter values in the fields to define the context of the definition:
In the Label field, enter text that describes the purpose of the circumstance definition.
To change the default identifier for the circumstance definition, click Edit, and then in the Identifier field, provide a unique value.
In the Template Name field, press the Down arrow key, and then select the circumstance template that your circumstance definition implements.
In the Context section, select the application to store the template.
In the Apply to field, press the Down arrow key and select the class that defines the scope of the circumstance definition.
In the Add to ruleset field, select the name and version of a ruleset that stores the circumstance definition.
To override the default work item that your application associates with this development change, in the Work item to associate field, press the Down arrow key, and then select a work item.
For more information about your default work item, see Setting your current work item.
Click Create and open.
On the Definition tab, click the column header to choose which operations the column supports:
- For columns that evaluate properties from the template against a single value, select an operator from the Use Operator list, for example >.
- For columns that evaluate properties from the template against a range of values, select the Use Range check box, and then choose operators from the Starting Range and End Range lists, for example >= and <=.
Click a cell in a table that you want to define, and then enter a value or an expression that evaluates properties in the template.For example: To evaluate loan amounts greater than 5000, use a single operator >, and then enter 5000.
To provide more values for evaluation, add rows to the table:
Note: As your application evaluates the table from top to bottom, to save time and resources, place the most likely outcomes at the top of the table.
- To add a row before the current cell, on the toolbar, click Insert Row Before, and then repeat step 6.
- To add a row after the current cell, on the toolbar, click Insert Row After, and then repeat step 6.
To ensure that your application can process the table, check the table for conflicts by clicking Show conflicts on the toolbar.Note: A warning icon appears in rows that are unreachable or empty.
- Circumstance rule examples
Assume that you have different pricing levels for your customers. You first define a base pricing rule for all customers. Then you qualify the base rule by creating circumstanced rules for customers at different buying levels. The property .CustomerType is part of the customer order and has values of "Silver" and "Gold". In this example, a customer has purchased a $100 item. Using the property and values, you create circumstanced instances of the base rules as shown here:
- Circumstance definitions
A circumstance is an optional qualification available for supported rule types and is built upon the base rule.
- Date combinations and business requirements
The following table lists the possible date combinations and the business-logic requirements they meet when you circumstance by date.
- Changing the scope of rules
Adjust your application to your specific business needs by changing scope of rules. For example, you can move a rule to another ruleset or class, so that you can reuse the rule in a different part of your application.
- Setting rule status and availability
Set rule status and availability to elaborate on the usage information that you provide, and ensure that users interact with the correct version of your rule at run time. By setting rule status and availability, you also define application behavior during rule resolution, and how users can interact with rules at design time. As a result, you ensure that your application works correctly even if users apply extensions and make modifications.
- Creating a rule
To save time and ensure that your projects adhere to the unique needs of your clients, create rules and data instances using reusable elements of your application. By combining a rule type, name, class, and ruleset, you provide a unique identity for each rule that you create.
- Building logic and calculating values in your application
Provide automations for calculating values and implementing logic so that your application can flexibly respond to unique conditions at run time. For example, you can create a process of transforming data, and, as a result, present users with relevant information when they perform work.