Skip to main content

Avalara AvaTax Mapping Functions

Reference for the Avalara AvaTax-specific functions you can use in Dynamic Formula mappings and mapping collection filters.

Overview

The Avalara AvaTax integration provides a set of ready-made functions you can call when building mappings. They handle common conversions and lookups for Avalara AvaTax, such as building a state or country model for an address, looking up a certificate exposure zone or exemption reason, or reading a value from your source data, so you don't have to write that logic yourself.

Where you can use these functions

These functions are available anywhere you write a formula for the Avalara AvaTax integration:

  • Dynamic Formula mappings: where a destination field's value is produced by a formula rather than mapped directly from a source field.

  • Mapping collection filters: where a formula decides whether a record should be processed.

  • Error filters: a mapping collection's error filter, which sits alongside its collection filter. When the error filter's formula resolves to true, the transfer raises an error that is held in the Error Logs for review and is not retried automatically.

  • Translation collections: where a translation entry uses a formula as its source value.

How to use them

  • Call a function by name and pass the values it needs in parentheses, for example: CreateStateModelFromName(name).

  • Each function's signature shows its name, the parameters it accepts (with their types), and the type of value it returns. Use it as the reference for exactly how to call the function.

  • Function names and formula syntax are case-sensitive, so type each name exactly as shown. Whether the values a function matches are treated as case-sensitive varies by function, and is called out in the relevant parameter's description.

  • Some of these functions are asynchronous (their signature returns a Task) and must be called with await; the rest are synchronous and are called directly. Each function's How to call it example shows the correct form.

  • Optional parameters are marked in the parameter table, along with the value used when you omit them.

  • Each function runs at sync time, against the data in your connected Avalara AvaTax account and your iPaaS.com subscription.

The functions are grouped below by the area of the integration they support.

Addresses: State and Country

Use these when preparing the state and country values on an address for Avalara AvaTax. The State and Country values Avalara expects are model objects; these builders create them from an ID, an ISO code, or a name.

CreateStateModel

What it does: Builds an Avalara State model from either a two-letter state code or a full state name. If the value is two characters long it is treated as the code (initials); otherwise it is treated as the name.

Signature: State CreateStateModel(string state)

How to call it: CreateStateModel(state)

Parameter

Type

Required

Default

Description

state

string

Yes

N/A

The state as a two-letter code (for example "CA") or a full name (for example "California").

Returns: State. An Avalara state model set from the supplied value, or nothing if the value is empty.

Example: CreateStateModel("CA") builds a state model from the code "CA"; CreateStateModel("California") builds one from the name.

When to use it: When mapping an address state to Avalara AvaTax and your source provides either the code or the name.

CreateStateModelFromId

What it does: Builds an Avalara State model from an Avalara state ID.

Signature: State CreateStateModelFromId(int id)

How to call it: CreateStateModelFromId(id)

Parameter

Type

Required

Default

Description

id

int

Yes

N/A

The Avalara state ID.

Returns: State. An Avalara state model set from the supplied ID.

Example: CreateStateModelFromId(5) builds a state model with ID 5.

When to use it: When mapping an address state to Avalara AvaTax by its Avalara state ID.

CreateStateModelFromInitials

What it does: Builds an Avalara State model from a state's two-letter code (initials).

Signature: State CreateStateModelFromInitials(string initials)

How to call it: CreateStateModelFromInitials(initials)

Parameter

Type

Required

Default

Description

initials

string

Yes

N/A

The two-letter state code (for example "CA").

Returns: State. An Avalara state model set from the supplied code.

Example: CreateStateModelFromInitials("CA") builds a state model with the code "CA".

When to use it: When mapping an address state to Avalara AvaTax and your source provides the two-letter code.

CreateStateModelFromName

What it does: Builds an Avalara State model from a full state name.

Signature: State CreateStateModelFromName(string name)

How to call it: CreateStateModelFromName(name)

Parameter

Type

Required

Default

Description

name

string

Yes

N/A

The full state name (for example "California").

Returns: State. An Avalara state model set from the supplied name.

Example: CreateStateModelFromName("California") builds a state model with the name "California".

When to use it: When mapping an address state to Avalara AvaTax and your source provides the full name.

CreateCountryModel

What it does: Builds an Avalara Country model from a two-letter code, a three-letter code, or a full country name. A two-character value is treated as the ISO initials, a three-character value as the abbreviation, and anything longer as the name.

Signature: Country CreateCountryModel(string country)

How to call it: CreateCountryModel(country)

Parameter

Type

Required

Default

Description

country

string

Yes

N/A

The country as a two-letter code ("US"), a three-letter code ("USA"), or a full name ("United States").

Returns: Country. An Avalara country model set from the supplied value, or nothing if the value is empty.

Example: CreateCountryModel("US") builds a country model from the two-letter code.

When to use it: When mapping an address country to Avalara AvaTax and your source provides a code or a name.

CreateCountryModelFromId

What it does: Builds an Avalara Country model from an Avalara country ID.

Signature: Country CreateCountryModelFromId(int id)

How to call it: CreateCountryModelFromId(id)

Parameter

Type

Required

Default

Description

id

int

Yes

N/A

The Avalara country ID.

Returns: Country. An Avalara country model set from the supplied ID.

Example: CreateCountryModelFromId(1) builds a country model with ID 1.

When to use it: When mapping an address country to Avalara AvaTax by its Avalara country ID.

CreateCountryModelFromInitials

What it does: Builds an Avalara Country model from a two-letter ISO country code.

Signature: Country CreateCountryModelFromInitials(string initials)

How to call it: CreateCountryModelFromInitials(initials)

Parameter

Type

Required

Default

Description

initials

string

Yes

N/A

The two-letter ISO country code (for example "US").

Returns: Country. An Avalara country model set from the supplied code.

Example: CreateCountryModelFromInitials("US") builds a country model with the code "US".

When to use it: When mapping an address country to Avalara AvaTax and your source provides the two-letter code.

CreateCountryModelFromAbbreviation

What it does: Builds an Avalara Country model from a three-letter country abbreviation.

Signature: Country CreateCountryModelFromAbbreviation(string abbreviation)

How to call it: CreateCountryModelFromAbbreviation(abbreviation)

Parameter

Type

Required

Default

Description

abbreviation

string

Yes

N/A

The three-letter country abbreviation (for example "USA").

Returns: Country. An Avalara country model set from the supplied abbreviation.

Example: CreateCountryModelFromAbbreviation("USA") builds a country model with the abbreviation "USA".

When to use it: When mapping an address country to Avalara AvaTax and your source provides the three-letter abbreviation.

CreateCountryModelFromName

What it does: Builds an Avalara Country model from a full country name.

Signature: Country CreateCountryModelFromName(string name)

How to call it: CreateCountryModelFromName(name)

Parameter

Type

Required

Default

Description

name

string

Yes

N/A

The full country name (for example "United States").

Returns: Country. An Avalara country model set from the supplied name.

Example: CreateCountryModelFromName("United States") builds a country model with the name "United States".

When to use it: When mapping an address country to Avalara AvaTax and your source provides the full name.

GetShortCodeByCountryName

What it does: Returns the two-letter ISO code for a country name. If the name is not found, the original value is returned unchanged; if the input is empty, nothing is returned.

Signature: string GetShortCodeByCountryName(string Country)

How to call it: GetShortCodeByCountryName(Country)

Parameter

Type

Required

Default

Description

Country

string

Yes

N/A

The country name to convert to a two-letter ISO code (for example "United States").

Returns: string. The two-letter ISO code, or the original input if no match is found, or nothing if the input is empty.

Example: GetShortCodeByCountryName("United States") returns "US".

When to use it: When mapping a country name to its two-letter ISO code.

Certificates

Use these when mapping exemption certificate data to Avalara AvaTax.

GetCertificateExposureZoneNameAsync

What it does: Looks up an Avalara certificate exposure zone by name or region and returns the matching zone name. Returns nothing if no zone matches. The match is not case-sensitive.

Signature: Task<string> GetCertificateExposureZoneNameAsync(string value)

How to call it: await GetCertificateExposureZoneNameAsync(value)

Parameter

Type

Required

Default

Description

value

string

Yes

N/A

The exposure zone name or region to look up in Avalara (for example "EU", "US", or "Europe").

Returns: string. The matching Avalara exposure zone name, or nothing if no zone matches.

Example: await GetCertificateExposureZoneNameAsync("EU") returns "EU" when a matching zone exists.

When to use it: When mapping an exemption certificate's exposure zone to Avalara AvaTax.

GetCertificateExemptionReasonNameAsync

What it does: Looks up an Avalara certificate exemption reason by name and returns the matching reason name. Returns nothing if no reason matches. The match is not case-sensitive.

Signature: Task<string> GetCertificateExemptionReasonNameAsync(string value)

How to call it: await GetCertificateExemptionReasonNameAsync(value)

Parameter

Type

Required

Default

Description

value

string

Yes

N/A

The exemption reason name to look up in Avalara (for example "RESALE" or "MANUFACTURING").

Returns: string. The matching Avalara exemption reason name, or nothing if no reason matches.

Example: await GetCertificateExemptionReasonNameAsync("RESALE") returns "RESALE" when a matching reason exists.

When to use it: When mapping an exemption certificate's exemption reason to Avalara AvaTax.

Customer Data

Use these when reading values out of your source data during mapping.

GetValueFromList

What it does: Reads a named property (for example City or PostalCode) from the first address in a customer address list, and returns it as text. Optionally reads from the billing address. Returns an empty string if the property is not present.

Signature: Task<string> GetValueFromList(object addressListData, string propertyName, bool isBilling = false, bool boolValue = false)

How to call it: await GetValueFromList(addressListData, propertyName)

Parameter

Type

Required

Default

Description

addressListData

object

Yes

N/A

The customer address list from your iPaaS.com source data (for example an iPaaS.com order's addresses).

propertyName

string

Yes

N/A

The property name to read (for example "City", "Line1", or "PostalCode").

isBilling

bool

No

false

When true, reads the property from the billing address.

boolValue

bool

No

false

A flag that influences the internal selection logic.

Returns: string. The requested property value from the first matching address, or an empty string if the property is not present.

Example: await GetValueFromList(addressListData, "City") returns the City value of the first address.

When to use it: When mapping a value from a customer address (such as city or postal code) into an Avalara AvaTax field.

GetPropertyValue

What it does: Returns the value of a named property from an object. Returns nothing if the object has no property with that name.

Signature: object GetPropertyValue(object obj, string propertyName)

How to call it: GetPropertyValue(obj, propertyName)

Parameter

Type

Required

Default

Description

obj

object

Yes

N/A

The object to read the property from.

propertyName

string

Yes

N/A

The name of the property to read (for example "City" or "PostalCode").

Returns: object. The property's value, or nothing if the object has no property with that name.

Example: GetPropertyValue(address, "City") returns the City value of the address object.

When to use it: When you need to read a single named property out of an object during mapping.

Related Documents

Did this answer your question?