Configuring a generic type in the local environment tree by using the Cast function
You can use the Cast function to define variables in a message map that are defined in the local environment tree, such as in the Variables folder.
About this task
LocalEnvironment.Variables.value_name
In
this example, Variables
is a generic element, and
you must define the required elements in it for each value_name.
You can also set values in the output local environment, Destination.specific_node
,
to override the behavior of a following node. For example:- For routing in the message flow, the map could set:
LocalEnvironment.Destination.RouterList.DestinationData[1].labelName
- To set a parameter to issue a REST request:
In this case,LocalEnvironment.Destination.REST.Parameters.parameter_name
Parameters
is a generic element, and you must define the required elements in it for each parameter_name. - To set an order in a filter, to be used
by a LoopBack request:
In this case, the order is a generic element, and you must define the required elements in it for each name.LocalEnvironment.Destination.Loopback.Request.filter.order[1].name
Procedure
To configure the local environment tree Variables or other generic element, so that you can use its elements as part of your transformations, complete the following steps:
Results
You have defined one local environment variable that can be used by other message flow nodes in your message flow for routing or filtering.
You can see the element Country under the local environment Variables folder in the message map.
Example
Another example:
If you set in an ESQL compute node two simple fields within the Variables folder of the Local Environment tree by using the following code:
SET Outputlocal environment.Variables.dec = 10.1;
SET Outputlocal environment.Variables.str = 'Some text';
To access these fields in a Mapping node by using the Cast function, you must create a schema file in your integration solution to define the elements and their type. Note that since the ESQL is not using any namespace to qualify these elements, the schema is also defined without a namespace declaration:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="dec" type="xsd:decimal"/>
<xsd:element name="str" type="xsd:string"/>
</xsd:schema>
Once the schema file is saved, you can then select the any element under the Variables section in the Local Environment tree, and use the context menu action Cast to add a Mapping cast for each of the elements "dec" and "str" that are required in the message map. For more information, see Mapping xsd:any on an input or output message.
What to do next
Define transforms between the input local environment tree and the output local environment tree. For more information, see Specifying a transform (mapping operation) and Transform types in the Graphical Data Mapping editor.