Calculating and Storing the Name of a Node

You can define an expression to calculate a node name during a request and then store that value when the request is completed and closed.

The calculated name can be based on the properties of the node, or the node's position in a hierarchy.

Example Use Cases

  • You can calculate a node name based on a sequence number. For example, you can concatenate a prefix like "CC_" with a sequence so that when you add nodes they are automatically named CC_0034, CC_0035, etc.
  • You can calculate a node name based on properties. For example, you can concatenate custom node data type properties together. Then, as you define the properties, the node name is automatically calculated. So, for custom property 1 = 120, custom property 2 = 200, and custom property 3 = 340, a node name of 120-200-340 is automatically calculated.

    Tip:

    You can also set up expressions on the node data type property to derive their values so that if you add a node name of 120-200-340 instead, the value for each property is derived as 120, 200, and 340 respectively. See Derived and Stored Properties.

  • You can calculate a node name based on hierarchy structural information such as parents, ancestors, and siblings. For example, you can concatenate a parent name plus the node description.
  • You can also use calculated node names to customize the default name when you add a new node. For example, when a user adds a node in the Entity node type, instead of the name defaulting to "New Entity Node", you could return a calculated name of "CC_####" and have your users manually fill in the appropriate values for ####.

Considerations

  • You can calculate a node name during the following operations:
    • Adding nodes interactively
    • Copying or modeling after a node
    • Loading request files
    • Synchronizing nodes via a subscription
  • During an Add action in a request, the node name is recalculated every time the node is changed.

    Note:

    When a node name is calculated based on a sibling list (for example, by finding the last sibling and adding 1 to it), be aware that the node name may change if other siblings are added after it and then the original node is updated.

    Also, depending on the request context, using the node.previousSibling object in an expression to calculate node names can have unexpected results. For best results, use node.siblings.max instead.

  • When displaying a calculated node name in a request:
    • If the node name expression returns a value, that value is displayed with an origin of Calculated.
    • If the expression returns a null value, then the calculated name keyword <cn ####> (where #### is a hash of the request item's created timestamp) is displayed with an origin of Calculated. See Understanding the Calculated Name Keywords.
  • You can overwrite the node name by manually entering a name. The origin displays Defined.
  • For nodes being added in a request, use the Clear action to clear a manually-entered name and go back to the calculated name, and use the Reset action to set the current location as the primary location (see Understanding Primary Locations) and to recalculate the node name based on the expression. See Clearing and Resetting a Calculated Value.
  • After a request has been completed and closed, the calculated node name is stored and the origin displays Defined. Unlike with Derived and Stored properties, the system does not retain the origin as Calculated and Stored.
  • Validations that are run in the context of a request that contains calculated node names will use the currently calculated name. That means, for example, that if the expression currently returns a null, the node name for the validation is "<cn ####>".
  • When searching for nodes in a request, the current name in the Add action is used for new nodes that have calculated names. That means, for example, that if the expression currently returns a null, you can search on "<cn ####>" in the node name.
  • When loading request files, use the <cn> or <cn ####> keyword in the name column of a request load file (where an expression is configured for the Core.Name property) or leave the name column blank to calculate the value for that node name. See Request File Processing with Calculated Names.

Note:

Defining a Calculated and Stored Property

  1. Inspect a Core.Name property definition.
  2. Select the application or node type that you want to calculate the node name for.
  3. From Default Type, select Calculate and Store.
  4. In Default Value, click the Expression button define expression.
  5. Define an expression to calculate the node name and click Apply. See Using Expressions to Define Custom Business Logic.

Understanding Primary Locations

If you are adding a node and then inserting the same node in multiple other locations, then internally the system designates the first location in a hierarchy where the node is added as the primary location and uses that to calculate the node name. All subsequent places where the node is inserted will use the calculated name from the first location.

Note:

If the first location where the node is added is in a list, the primary location is set the first time it is inserted into a hierarchy.

For example, suppose you had an expression that calculated the node name by concatenating the node's parent's name with a property on the node (for this example, that property has a value of ABC). When you add the node under parent 111, the name is calculated as 111-ABC. If you then insert the node under parent 222, the name is still 111-ABC, because 111 is the primary location.

There are multiple ways to change a node's primary location:

  • If you move a node in the request from its primary location, the new location becomes the primary location and the name is recalculated.

  • If you remove the node from the primary location during the request, the next location where it was inserted becomes the primary location.

  • If you have a node in multiple places and you want to manually change which location is the primary location, use the Reset action. See Clearing and Resetting a Calculated Value

Clearing and Resetting a Calculated Value

Use Clear to clear a manually defined name and go back to the calculated name. The Clear action is available only for nodes that were added in this request with a default type of Calculate and Store that have a name that was manually entered.

Use Reset to set the primary location for the calculated name to the current location (see Understanding Primary Locations) and to recalculate the node name based on the current location. The Reset action is available only for nodes that were added in this request with a default type of Calculate and Store that do not have a name that was manually entered.

You can also use Reset to recalculate a node name if you have taken an action outside of the node that would affect the node name (for example, if you change a Parent property and you want to recalculate the node name based on the new property).

Validations and Calculated Node Names

When a request is validated, the current name in the Add action is used for new nodes that have calculated names, with one exception: If the current name is one of the keywords (<cn> or <cn ####>), the minimum and maximum length validations are skipped. This enables a submitter to submit a request with one of the keywords in the name so that an approver or enricher can add the required information to calculate the name.

The minimum and maximum length validations are run when requests are approved or committed.

Calculated Names and Subscriptions

When you set up a subscription using a calculated name, the name is calculated in the source viewpoint and the resulting name is passed in the subscription requests to the target viewpoints. If you want to have the node name calculated in the target viewpoint, you must set up a property transformation in the node type converter for the subscription (see Working with Node Type Converters) to transform the name to a blank value or one of the calculated name keywords (<cn> for Adds, or <cn ####>, where #### is a unique identifier string, for Adds with Inserts). See Understanding the Calculated Name Keywords.

Note:

If you want to use an Alternate Name when available, transform the name to a blank value. If you always want to use the calculated name in the target viewpoint, transform the name to one of the keywords.