Using References

The most basic formula is a reference that queries a specific value in an attribute. The syntax of a reference query is defined as a set of dot-separated fields.

<unit>.<path>.<attribute>

where

  • <unit> is the name of the Connector unit or flow unit

  • <path> is the parameter type in the unit

  • <attribute> is the value passed to the parameter

For example, this reference formula follows the object structure of a given Connector.

findvariantbyid.body.engine_type_id

where

  • findvariantbyid is the Connector

  • body is the path to the attribute

  • engine_type_id is the name of the attribute

Based on the Connector, this reference formula resolves to the following value, in this case an integer value.

547290
Reference example

To quickly add a reference to the formula editor field, click an attribute from the source and the reference will be automatically added.

Modifying a reference

Starting with the reference, you can use Axel-f functions as well as operators to transform the output to a different output. This is done in the Formula editor.

For example, let's say we have a project that uses a REST endpoint and a connector called allVariants. It includes a parameter that outputs a currency value priced in Euros. However, suppose we want the currency value priced in US dollars. We would use several Axel-f functions and some operators.

The original formula in the Formula editor of the Mapping dashboard is shown below for the endpoint.

Original reference formula

The original reference formula looks like this.

# Property formula:
allVariants.body.[].base_price_EUR
‚Äč
# Result:
[547290]

Using this reference formula, we modify it so that every returned record's base price is in US dollars rather than Euros.

Using the MAP, FN and ROUND Axel-f functions, as well as the * operator, we modify this reference formula using the following steps.

We first want to change the name of the parameter:

  • In the Mapping dashboard, hover over the parameter name base_price_EUR and click Edit name to make the field editable

  • Change the name of the parameter from base_price_EUR to base_price_USD

  • Click Save

Changing the name of a parameter in the Mapping dashboard can only be done in the Endpoint. To change the name of a parameter in a Connector, it can be done in the Edit Connector page for a Connector.

Next, let's change the formula for the property base_price_USD in the Formula editor.

  • Hover over the parameter value for base_price_EUR to reveal the dropdown and click Edit formula to open the Formula editor.

  • Currently, the field contains the following reference formula:

    • allvariants.body.[].base_price_EUR

  • Using the Axel-f functions MAP, FN and ROUND, type the following into the field:

    • MAP(FN(x, ROUND(x * 1.1, 2)), allvariants.body.[].base_price_EUR)

  • If the changes were made correctly, a Formula valid message appears.

  • Click Save to save the changes.

Xapix helps you use the Formula field. See Entering functions.

The value of the parameter base_price_USD is now 25802.46.

Modified reference formula

Once you have made the changes, click Done to close the Mapping editor.

You need to republish the project after making and changes to the project.