Combine Multiple Text Strings Into a Single Text Attribute

To combine the values of two or more non-Boolean attributes or text strings into a single text value, you use the string concatenation function. For example, you might want to combine 'the person's first name' (Harriet) with 'the person's last name' (Jones) to create 'the person's name' (Harriet Jones).

The concatenation function is commonly used to create attributes that can be substituted into screen headings and labels.

The syntax for using the string concatenation function is:

  • the concatenation of <text1> + <text2> + . . .
  • <text1> + <text2> + . . .

Examples of the use of the concatenation function in rules are given in the following table.

Table 1. Examples of the use of the concatenation function
Example rule Inputs Outputs

the person’s name = the concatenation of the person’s first name + " " + the person's last name

the person's first name: Oliver

the person's last name: Smith

the person’s name = Oliver Smith

the summary description = "The contact is applying for " + the basic insurance product + " cover with " + the type of extras cover + " extras, paying an annual premium of " + the total annual premium as text + ".

the basic insurance product: Couples

the type of extras cover: Basics

the total annual premium as text: $950.00

the summary description = The contact is applying for Couples cover with Basic extras, paying an annual premium of $950.00.

the contact’s task = the concatenation of "Add " + the contact's email address + " to the marketing email distribution list"

the contact's email address: a.abimbola@example.com

the contact's task is Add a.abimbola@example.com to the marketing email distribution list

Note: The (" ") part of the rule will insert a blank space between the text inputs. Similarly you could use (", ") to insert a comma and blank space in between text attributes. To insert a quotation mark into the concatenated text, use the Quote function.

You can use non-Boolean attributes of any type with this function by including the Text function.

For example:

the order identifier = the concatenation of "Order for " + Text(the order amount) + " on " + Text(the order date)

the map URL = "https://www.google.com.au/maps/place/" + Text(the GPS location latitude) + "," + Text(the GPS location longitude)

Note that when using the concatenation function with an attribute that is collected with a value list, the function will return the value list item's display text.

For example, if you had this rule:

the address = street number + " " + street name + ", " + city + ", " + state

where the state is collected with a value list like this:

A value list in Policy Modeling showing values and display values for US states

the rule would return the display text for the 'state' attribute. For instance:

the address is 500 Oracle Parkway, Redwood Shores, California

If you want to get the list's value instead, you can use the concatenation function with the Value function.

For example, the following rule:

the address = street number + " " + street name + ", " + city + ", " + Value(state)

would return:

the address is 500 Oracle Parkway, Redwood Shores, CA