Cast Node

The cast node allows you to assert that you know that an object will be a specific class, or that you want to pretend it is of that class. This allows you to use attributes from that class in the Rule or Action builder that would not show them otherwise.

The cast doesn’t change the class of the object and it doesn’t do anything when the Rule or Action is running. It simply tells the Rule and Action builder to list the attributes for the class you cast it to.

     Note: The Class and Attribute you Cast to must be present in the Schema selected as your Context.

The Cast node requires you to define:

  • The named object to cast from

  • The class to cast to

  • (Optional) The name to give the cast object

     Note: Only use cast in a Rule or Action once you have asserted that the class is of the type you are about to cast it to or at least has the attributes that you want to access.

For example, you could achieve this by using a check that class_has_attribute("$ClassName$", $AttributeName$)=true, or by using a Check That that ensures that Class Name equals "$ClassName$". You can see this utilised in a Rule by following the example below.

Example

In the following example, we can see the Root node has been set against All objects.

In the Rule we need to use the BUILDING_TYPE attribute during an IF...Then...Else check. But, the BUILDING_TYPE is unique to the BUILDING class, so we must use the Cast node.

First, we need to check that the object is of the expected Class, in this instance BUILDING. This is important to avoid any potential errors.

Next, the Then node will use the Cast function to access the BUILDING_TYPE attribute, this allows us to use the Else node to perform additional checks on all other Classes.

Cast node utilised in a Rule
An example Cast Node used in a Session