You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/logic-apps/rules-engine/add-rules-control-functions.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ This guide describes how to optimize code for your rules engine by using control
34
34
35
35
To add object instances to the rules engine's working memory, use the **Assert** function in the Microsoft Rules Composer. The engine processes each object instance according to the conditions and actions that are written against the instance's type using the match-conflict resolution-action phases.
36
36
37
-
The following table summarizes the **Assert** function behavior for the supported asserted entities and instance types, including the number of resulting instances created in the engine for each asserted entity and also the type that is applied to each instances to identify them.
37
+
The following table summarizes the **Assert** function behavior for the supported asserted entities and instance types, including the number of resulting instances created in the engine for each asserted entity and the type applied to each instance for identification.
38
38
39
39
| Entity | Number of instances asserted | Instance type |
@@ -266,7 +266,7 @@ You can either retract the **TypedXmlDocument** entity associated with an **orde
266
266
267
267
For example, **product** is a **TypedXmlDocument** entity below the **orderline** object and is associated with the **TypedXmlDocument** entity for **order**, not the **TypedXmlDocument** entity for **orderline**. In most instances, this distinction isn't important. However, if you retract the **order** object, the **orderline** and **product** objects are also retracted. If you retract the **orderline** object, only that object is retracted, not the **product** object.
268
268
269
-
The engine only works with and tracks the object instances, which are **TypedXmlDocument** instances, that the engine created when the **TypedXmlDocument** entity was initially asserted. If you create additional nodes, such as sibling nodes for a node that was selected through a selector in the ruleset, these nodes aren't evaluated in rules unless **TypedXmlDocument** entities are created and asserted for them. If you assert these new, lower-level **TypedXmlDocument** instances, they are evaluated them in rules, but the top-level **TypedXmlDocument** entity doesn't have knowledge about them. When the top-level **TypedXmlDocument** is retracted, the new, independently asserted **TypedXmlDocument** entities aren't automatically retracted. As a result, if new nodes are created, retract and reassert the full **XmlDocument** as the typical and most straightfoward step to take.
269
+
The engine only works with and tracks the object instances, which are **TypedXmlDocument** instances, that the engine created when the **TypedXmlDocument** entity was initially asserted. If you create additional nodes, such as sibling nodes for a node that was selected through a selector in the ruleset, these nodes aren't evaluated in rules unless **TypedXmlDocument** entities are created and asserted for them. If you assert these new, lower-level **TypedXmlDocument** instances, they are evaluated them in rules, but the top-level **TypedXmlDocument** entity doesn't have knowledge about them. When the top-level **TypedXmlDocument** is retracted, the new, independently asserted **TypedXmlDocument** entities aren't automatically retracted. As a result, if new nodes are created, retract and reassert the full **XmlDocument** as the typical and most straightforward step to take.
270
270
271
271
The **TypedXmlDocument** class provides useful methods that you can call within a custom .NET member as part of an action. These methods include the capability to get the **XmlNode** associated with the **TypedXmlDocument** or the parent **TypedXmlDocument**.
272
272
@@ -280,7 +280,7 @@ The **TypedXmlDocument** class provides useful methods that you can call within
280
280
281
281
1. From the **XML Schemas** tab, drag the top-level node for the schema into the argument for the **Retract** function.
282
282
283
-
This top node ends in the **.xsd** extension and represents the document root node, not the document element node. The node has a **/** selector that refers to the initial **TypedXmlDocument**. When you retract the parent **TypedXmlDocument**, all **TypedXmlDocument** child entities associated with the **TypedXmlDocument** are removed from working memory, which include all the **TypedXmlDocument** entities created by calling the **Assert** function, based on selectors used in the ruleset.
283
+
This top node ends in the **.xsd** extension and represents the document root node, not the document element node. The node has a **/** selector that refers to the initial **TypedXmlDocument**. When you retract the parent **TypedXmlDocument**, all **TypedXmlDocument** child entities associated with the **TypedXmlDocument** are removed from working memory, including all the **TypedXmlDocument** entities created by calling the **Assert** function, based on selectors used in the ruleset.
284
284
285
285
#### Retract a child TypedXmlDocument entity
286
286
@@ -330,7 +330,7 @@ For example, if you use the **Reassert** function on a .NET object, the rules en
330
330
331
331
1. Remove any actions on the agenda for rules that use the object in a predicate or action.
332
332
333
-
1.Asssert the .NET object back into working memory and evaluate as a newly asserted object.
333
+
1.Assert the .NET object back into working memory and evaluate as a newly asserted object.
334
334
335
335
1. Reevaluate any rules that use the object in a predicate and add those rules' actions to the agenda as appropriate.
336
336
@@ -412,11 +412,11 @@ To reassert an object into the rules engine for reevaluation, based on the new d
412
412
413
413
1. From the **.NET Classes** tab, drag the class into the argument for the **Update** function.
414
414
415
-
Typically, you use **Assert** to place a new object in the rules engine's working memory, and use **Update** to update an already existing object in working memory. When you assert a new object as a fact, the engine reevaulates the conditions in all the rules. However, when you update an existing object, only conditions that use the updated fact are reevaluated, and actions are added to the agenda, if these conditions evaluate to true.
415
+
Typically, you use **Assert** to place a new object in the rules engine's working memory, and use **Update** to update an already existing object in working memory. When you assert a new object as a fact, the engine reevaulates the conditions in all the rules. However, when you update an existing object, only conditions that use the updated fact are re-evaluated, and actions are added to the agenda, if these conditions evaluate to true.
416
416
417
417
For example, suppose you have the following rules and that the objects named **ItemA** and **ItemB** already exist in working memory.
418
418
419
-
-**Rule 1** evaluates the **Id** property in **ItemA**, sets the **Id** property on **ItemB**, and then reasserts **ItemB** after the change. When **ItemB** is reasserted, the engine treats **ItemB** as a new object, and the engine reevaluates all rules that use **ItemB** in the predicates or actions. This behavior makes sure that the engine reevaluates**Rule 2** against the new value in **ItemB.Id** as set in **Rule 1**.
419
+
-**Rule 1** evaluates the **Id** property in **ItemA**, sets the **Id** property on **ItemB**, and then reasserts **ItemB** after the change. When **ItemB** is reasserted, the engine treats **ItemB** as a new object, and the engine re-evaluates all rules that use **ItemB** in the predicates or actions. This behavior makes sure that the engine re-evaluates**Rule 2** against the new value in **ItemB.Id** as set in **Rule 1**.
420
420
421
421
**Rule 1**
422
422
@@ -435,19 +435,19 @@ For example, suppose you have the following rules and that the objects named **I
435
435
THEN ItemB.Value = 100
436
436
```
437
437
438
-
The capability to reassert objects into working memory gives you explicit control over the behavior in forward-chaining scenarios. However, this example reveals a side effect from reassertion where **Rule 1** is also reevaluated. With **ItemA.Id** unchanged, **Rule 1** again evaluates to **true**, and the **Assert(ItemB)** action fires again. As a result, the rule creates an endless loop situation.
438
+
The capability to reassert objects into working memory gives you explicit control over the behavior in forward-chaining scenarios. However, this example reveals a side effect from reassertion where **Rule 1** is also re-evaluated. With **ItemA.Id** unchanged, **Rule 1** again evaluates to **true**, and the **Assert(ItemB)** action fires again. As a result, the rule creates an endless loop situation.
439
439
440
440
#### Prevent endless loops
441
441
442
442
You must be able to reassert objects without creating endless loops. To avoid such scenarios, you can use the **Update** function. Like the **Reassert** function, the **Update** function performs the **Retract** and **Assert** functions on the associated object instances that are changed by rule actions, but with the following key differences:
443
443
444
444
- On the agenda, actions for rules where the instance type is only used in the actions, not the predicates, stay on the agenda.
445
445
446
-
- Rules that only use the instance type in actions aren't reevaluated.
446
+
- Rules that only use the instance type in actions aren't re-evaluated.
447
447
448
-
As a result, rules that use the instance types in either only the predicates or both the predicates and actions are reevaluated. and their actions are added to the agenda as appropriate.
448
+
As a result, rules that use the instance types, either in only the predicates or both the predicates and actions, are re-evaluated, and the rules' actions are added to the agenda as appropriate.
449
449
450
-
By changing the preceding example to use the **Update** function, you can make sure that the engine reevaluates only **Rule 2** because the condition for **Rule 2** uses **ItemB**. The engine doesn't reevaluate **Rule 1** because **ItemB** is only used in the actions for **Rule 1***, eliminating the looping scenario.
450
+
By changing the preceding example to use the **Update** function, you can make sure that the engine re-evaluates only **Rule 2** because the condition for **Rule 2** uses **ItemB**. The engine doesn't reevaluate **Rule 1** because **ItemB** is only used in the actions for **Rule 1***, eliminating the looping scenario.
451
451
452
452
**Rule 1**
453
453
@@ -472,7 +472,7 @@ THEN ItemA.Value = 20
472
472
Update(ItemA)
473
473
```
474
474
475
-
The predicate uses **ItemA**, so the engine reevaluates the rule when **Update** is called on **ItemA**. If the value for **ItemA.Id** isn't changed elsewhere, **Rule 1** continues to evaluate as **true**, which causes calling **Update** again on **ItemA**.
475
+
The predicate uses **ItemA**, so the engine re-evaluates the rule when **Update** is called on **ItemA**. If the value for **ItemA.Id** isn't changed elsewhere, **Rule 1** continues to evaluate as **true**, which causes calling **Update** again on **ItemA**.
476
476
477
477
As the rule designer, you must make sure to avoid creating such looping scenarios. The appropriate approach to fix this problem differs based on the nature of the rules.
Copy file name to clipboardExpand all lines: articles/logic-apps/rules-engine/add-rules-operators.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,11 +54,11 @@ You can add an arithmetic operator to a condition or action in a rule. The follo
54
54
55
55
- If the operands have different types, the rules engine performs automatic numeric promotion where the engine converts the smaller operand type to the larger operand type.
56
56
57
-
For example, if you use the **Add** operator with an operand that has **int** type and an operand that has **long** type, the engine converts **int**type to **long**before the engine performs the **Add**operation.
57
+
For example, suppose you use the **Add** operator on an operand that has **int** type and an operand that has **long** type. Before the engine performs the **Add**operation, the engine converts the **int**type to the **long**type.
58
58
59
59
- If the engine can promote both operands to a common type, the engine supports double promotion.
60
60
61
-
For example, if you use the **Add** operator with an operand that has **int** type and an operand that has **uint** type, the engine converts both operand types to **long**before the engine performs the **Add**operation.
61
+
For example, suppose you use the **Add** operator on an operand that has **int** type and an operand that has **uint** type. Before the engine performs the **Add**operation, the engine converts both operand types to the **long**type.
0 commit comments