New
- Last Updated: March 24, 2022
- 2 minute read
- Corticon
- Version 6.3
- Documentation
SYNTAX
<Entity>.new[<Expression1>,<Expression2>…]
Entity> with attribute values defined by optional
<Expression>. Expressions (when present) should
be written as assignments in the form: attribute = value. The attribute used in <Expression> (when present) must be an attribute of <Entity>.The Operators row in the table of Summary Table of Vocabulary Usage Restriction does not apply. Special exceptions: new may only be used in Action Rows (section 5 in Sections of Rulesheet that correlate with usage restrictions).
The following Rulesheet uses .new to create a newEntity2
element in collection1 when Entity1 has a string1 value equal to 'PO 123-ABC'. An alias is not required
by the .new operator, because it is possible to create a new entity
at the root level, without inserting it into a collection. The collection1 alias used here is required by the += (Associate Element to collection) operator.A sample Ruletest
provides 2 collections of Entity1. Input and Output
panels are illustrated below:
Behavior of
the .new operator
The .new operator does not consider
implied conditions of non-mandatory attributes (from the initialize expressions) during
execution (in other words, a .new operator always fires
when explicit conditions are met).
Each initialize expression within a .new… expression will be executed (or not) depending upon implied
conditions; that is, if any input to the expression is null, the target attribute
remains null. Another case where an implied condition would prevent a .new operator for executing is where the new entity is a
target to an association assignment and the parent of that association does not exist.
The following examples assume that all attributes are not mandatory.
- Rule 1:
Executes only ifIF entity1.attr1 > 10 THEN Entity2.new[attr1 = entity1.attr2]entity1exists,entity1.attr1is not null, andentity1.attr1 > 10. The newEntity2.attr1will be left as null ifentity1.attr2is null. - Rule 2:
Will always execute.Entity2.new[attr1 = entity1.attr1 + entity1.attr2]Entity2.attr1will remain null ifentity1does not exist, orentity1.attr1is null, orentity1.attr2is null. - Rule 3:
Will execute only ifentity1.assoc2 += Entity2.new[attr1 = entity1.attr1]entity1exists.Entity2.attr1will remain null ifentity1.attr1is null. - Rule 4:
This action will always fire.Entity2.new[attr1 = entity1.assoc1.attr1]entity2.attr1will remain null ifentity1does not exist, orentity1.assoc1does not exist, orentity1.assoc1.attr1is null. Note that this action will fire multiple times ifentity1.assoc1contains multiple entities (once for each entity contained in theentity1.assoc1collection).