How sets interact with the rest of a blueprint
Summarize
Summary of How sets interact with the rest of a blueprint
This document explains how sets within a blueprint interact with other fields in the same blueprint, focusing on the implications of field relationships when sets are involved. It clarifies the behavior of fields inside sets versus those outside sets, especially when sets have multiple indexes (instances).
Show less
Key Concepts of Set Interaction
- Fields inside a set: Each index of a set can have different values for its fields. Fields inside a set do not influence fields outside the set directly.
- Fields outside a set: These fields can influence fields inside the set because their value is singular and consistent across all indexes.
- Indexes independence: Each index in a set operates independently. Rules applied to fields within the set affect only the specific index and do not cross-influence other indexes.
- Ambiguous conditions: Conditions referencing set fields and trying to influence fields outside the set can be ambiguous and are not valid because outside fields cannot resolve multiple differing set values.
Examples of Rule Validity
- Invalid rule example: A rule that tries to set a field outside the set based on a set field condition (e.g., if setFieldA == Video then set field2) is ambiguous and should be avoided.
- Valid rule example: A rule where a field outside the set controls options or behavior of fields inside the set (e.g., if field1 == Mammals then set options on setFieldA) is valid and applies uniformly to all set indexes.
- Independent index rules: Rules can be written to apply conditions and actions within the same set index independently, such as setting setFieldB = true if setFieldA == Video for each index separately.
Extending Set Impact Outside the Set
Although direct influence from set fields to outside fields is restricted, you can enable interaction using:
- Product rules: When defined using set fields, product rules apply per index to affect the Bill of Materials (BOM) differently based on each index's field values.
- Set aggregates: Aggregates like Sum, Average, Min, Max, and Count summarize values across set indexes into a single field variable. These aggregate fields behave like regular outside fields and can influence other fields in the blueprint.
Practical Impact for ServiceNow Customers
Understanding how sets interact within blueprints helps you design rules and configurations that behave predictably in complex scenarios. Sets allow for multiple indexed entries with independent values, but require careful use of rules to avoid ambiguous logic. Using set aggregates and product rules extends the usefulness of sets by enabling summarized or collective influence on the blueprint outside the set, supporting more complex and dynamic configurations.
The implications of sets when used in blueprints.
Suppose you have a blueprint with the following fields:
- field1
- field2
- setFieldA
- setFieldB
The setFieldA and setFieldB fields are part of a set named sampleSet. The field1 and field2 fields are not part of a set, but they are in the same blueprint as sampleSet. For our case, assume that sampleSet has a size of 2. That structure would look something like this:
Because a field can have a different value for each set index, a field in the set cannot influence a field outside the set (such as field2). However, fields outside the set (such as field1) can influence fields in the set. See the diagram:
Example: Ambiguous conditions
If in sampleSet index 1, setFieldA=Video and in sampleSet index 2, setFieldA=Audio, we cannot have the following rule:
- Condition: “if setFieldA==Video
- Action: set field2 to mp4
For index1, the condition is true, and the rule fires. For index2, the condition is false, and the rule does not fire. Because field2 is outside the set, it is not clear whether the rule should fire.
However, you can write rules for fields that affect other fields in the same set. These rules are independently applied to each index. Fields in indexes cannot influence fields in other indexes.
Example: A valid rule
The following rule is valid:
- Condition: field1 == Mammals
- Action: Include the following field options on setFieldA: [“Lions”, “Tigers”, “Bears”]
The field options Lions, Tigers, and Bears are present for each index in sampleSet.
Example: Independent indexes
Suppose in sampleSet index 1, setFieldA=Video and in sampleSet index 2, setFieldA=Audio, and the following rule is set:
- Condition: If setFieldA == Video
- Action: setFieldB = true
For index1, the condtion is true, and the rule fires. For index2, the condition is false, and the rule does not fire. Therefore, setFieldB for index 1 is true, but the rule does not fire for the second index. Each index is independent of the other indexes.
A set that is isolated from the rest of the blueprint is not very useful, but there are ways that the set can affect the blueprint outside of the set. First, if a Product rule is created using fields in the set, each Index in the set uses the Product rule to affect the BOM when the conditions are met. This is beneficial because you can write a single rule that each Index of the set follows differently, depending on the field values in that index.
If we want to have set fields affect fields outside the set, we have to use the set aggregates. There are five set aggregates: Sum, Average, Min, Max and Count. Each created aggregate will have a field variable name (with special formatting). This is because the aggregate fields operate like any other field outside the set, and they can influence other fields.