Left trim

See also: Trim, Right trim

Value resolver – Abstract

Purpose: Removes leading whitespace characters from a string passed as input value.


images/download/attachments/106958174/image2022-6-29_17-14-24-version-1-modificationdate-1656515664168-api-v2.png

The Left trim value resolver removes leading whitespace characters from a string passed as input value.

  • If no value ($null) is present as input value, no value ($null) is returned.

  • For input values that are not strings, their string mapping is processed.

Configuration

The Left trim value resolver expects a string as input value and does not use any parameters.

Example

Within an event handler, a list of Addresses is processed in a For each loop event action.

In this case, information for the 'Country' (countryCode) and 'Zip code' (zipcode) fields should be combined into a common string according to the following logic:

[countryCode-]zipcode
  • The two-character country code (ISO-3166 alpha-2) should therefore appear separated from the Zip code by a minus sign if the address specifies a Country.

  • If the Country is not specified, only the Zip code should appear without a prefix.

Runtime example:

  • The first example address uses 'Germany' (DE) as the country.

  • The second sample address does not specify a country. The output string appears without a preceding minus sign.

NOTE◄ It is assumed in the example that the list does not contain any addresses without a Zip code, so that this special case does not have to be considered.

images/download/attachments/106958174/image2022-6-29_16-34-55-version-1-modificationdate-1656513295637-api-v2.png

Configuration:

The screenshot on the right shows a section of the For each loop event action block, which processes a list of Addresses step by step. For each iteration, exactly one address is available as a reference object, which is available as an input value for value resolvers in the context of the mapped Show alert (Popup) event action.

The content of the Message is obtained from the address in the input value by a chain of value resolvers:

  • IIn the first step, a Concat strings value resolver concatenates the values of the countryCode.name and zipcode fields, inserting a space character as a separator (see second substring). At first, it does not matter whether these fields are filled or empty.

  • If no 'country' is specified for an address, the first substring countryCode.name returns no value. Then the string passed to the following Left trim value resolver starts with statically defined blank characters, which are then removed.

  • The input value for the third step of the chain is then a string that contains a space character only if this separates 'country' and 'Zip code' from each other. The Replace text value resolver replaces this space with a minus sign.

NOTE◄ The solution assumes that neither the 'country codes' (countryCode.name) stored in the dynamic enumeration Country nor the Zip codes entered in addresses can contain a space character. Otherwise these are also replaced by minus signs.

images/download/attachments/106958174/image2022-6-29_17-16-38-version-1-modificationdate-1656515798873-api-v2.png

NOTE◄ Instead of the space character, it would also be possible to use the minus sign directly as a separator in the Concat strings value resolver here. The Left trim value resolver would then be pointless. And the Replace text value resolver would then have to take over its function for the special case 'no country selected' and remove the leading minus sign, if any. A very simple regular expression makes this possible:

  • Search text: ^-

  • Replace with: blank character string ("")

  • Regular expression?: images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/check.svg

images/download/attachments/106958174/image2022-6-29_17-17-37-version-1-modificationdate-1656515857896-api-v2.png