Step 3: Defining, Publishing, and Deploying the Business Policy for Contoso
In this step, you create a business policy that reserves a set quantity of units for each product that Contoso manufactures to be used in case of an emergency.
To add a new policy
In the Business Rule Composer, in the Policy Explorer pane, right-click Policies, and then click Add New Policy.
Name the new policy 3A2PriceAvailabilityPolicy, and then press Enter.
To add a policy rule to enforce the emergency quantity needs
Right-click Version 1.0 (not saved) under 3A2PriceAvailabilityPolicy, and then click Add New Rule.
Name the rule Emergency Supply Rule - Quantity Exhausted, and then press Enter.
In the Business Rule Composer, in the right pane, right-click Conditions under the IF pane, point to Predicates, and then click the Less than equal predicate.
In the Facts Explorer pane, expand Vocabularies, expand 3A2PriceAvailabilityVocabulary, expand Version 1.0 - Published, select Quantity Available, and drag it onto the
argument1
placeholder on the composer surface.Repeat step 4 by dragging Emergency Quantity Needed onto the
argument2
placeholder.Select Final Quantity Available, and then drag it onto Actions in the THEN pane.
To add a policy to revise the Number Available field in the response
Right-click Version 1.0 (not saved) under 3A2PriceAvailabilityPolicy, and then click Add New Rule.
Name the new rule Emergency Supply Rule - Quantity Available, and then press Enter.
In the Business Rule Composer, in the right pane, right click Conditions under the IF pane, point to Predicates, and then click the Greater than predicate.
In the Facts Explorer pane, expand Vocabularies, expand 3A2PriceAvailabilityVocabulary, expand Version 1.0 - Published, select Quantity Available, and then drag it onto the
argument1
placeholder on the composer surface.Repeat that same step by dragging Emergency Quantity Needed onto the
argument2
placeholder.Select Final Quantity Available, and then drag it onto Actions in the THEN pane.
In the Facts Explorer pane, expand Version 1.0 - Published under Functions, and drag the
Subtract
function onto the 0 argument next to Final Quantity Available in the THEN pane.Drag Quantity Available (under 3A2PriceAvailabilityVocabulary) and drop it on the
value1
placeholder in the THEN pane.Drag Emergency Quantity Needed, and drop it on the
value2
placeholder in the THEN pane.
To save, publish, and deploy the business policy
In the Policy Explorer pane, right-click Version 1.0 (not saved) under 3A2PriceAvailabilityPolicy, and then click Save.
Right-click that same node, and then click Publish.
Right-click that same node, and then click Deploy.