String templates

Restriction: As of the Summer 2023 release, the ability to set up exports using StringTemplate is deprecated. Customers that had StringTemplate exports prior to Summer 2023 may continue to use those exports, and they will also still be able to set up new ones using StringTemplate. If you require the use of StringTemplate, submit a Feature activation request so that Medallia teams can validate the use of this now-deprecated feature.

Export string templates define the custom format of text export files, where file has a body section containing the exported record data, and optional header and footer sections. When using a string template, the formatting options define the content and format of the file, and optionally transform the content when necessary.

This illustration shows how to create a CSV file using a '|' separator instead of a comma. The output includes a header and footer, and 10 rows of body text.

Example csv file with heading, body, and footer

Options

Header, Body, & Footer templatesDefines the content Each in the header, body, and footer sections of the export. Each template is a single-line that defines the output. See below for details about each section.
String transformString transformations convert existing field values to new values in the export results. For example, you can convert the values of Alt Set sequence numbers to meaningful labels like “Yes” or “No”. See  String transformations, below, for details.
Escape regular expressionSearches all exported data looking for a regex match. Any matches are replaced by the Escape replacement value.
Tip: When exporting customer-supplied text, such as comment fields, use regex to strip or transform commas in those text fields.
Escape replacementReplaces the matches found by Escape regular expression with this value. Leave this property blank to remove the found values from the export.
Restriction: The String Template export is always encoded in UTF-8, regardless of the Encoding property value.

Exporting tab characters

To use a tab separator, first enter the tab character in a text editor, such as Text Wrangler or Notepad, and then copy that character into the template string. This is because the browser catches the tab if you type it in the template string.

To open a tab-separated file in Excel, set the filename extension to .xls.

Exporting CRLF

On rare occasion a company requires the exported text file to use CRLF (carriage-return line-feed) line terminators. By default, exports are terminated with LF (line-feed) only. (Most import systems can be configured to accept either format.)

To use CRLF instead just LF, append the $\r$ template variable to the end of the template line. For example:

$cells; separator="|"$$\r$

String transformations

String transformations convert existing field values to new values in the export. This is especially useful to convert A-Field values to something meaningful to the system that will use the exported record

The syntax for a transformation is:

KeyName { recordValue = exportValue }

When there are multiple values in the fields, such as for Alt Sets, separate the assignments with a vertical bar, like this:

q_succeeded { 0 = Failed | 1 = Passed }

You can include one transformation for each field. To include multiple fields, place each on its own line in the String transform field. Note assignments can also be one-per-line.

q_succeeded {
   0 = Failed |
   1 = Passed
}
q_was_greeted {
   0 = No |
   1 = Yes |
   3 = Dont recall
}

Values that do not have an assignment are not changed. In the last example above, if there was no assignment for the three (3) value, the export would include 3 while the other two values are No and Yes.

The Enumerates alternative set format setting sets the type of the record value before the transformation. When that property is set to output Name instead of Sequence number, use the name value in the transformation. For example:

e_status { DELIVERY_BOUNCED = Y | COMPLETION_PENDING = N | COMPLETED = N | READY_FOR_SE = N | SURVEY_ENGINE_ONLY = N | EXCLUDED = N | NO_INVITE = N | READY_FOR_BROADCASTER = N | TEST_SURVEY = N | DELIVERED_TO_BROADCASTER = N | RETRY_DELIVERY_LATER = N | DELIVERY_FAILED = N | DELIVERED = N | DELIVERED_AND_REMINDED = N | DELIVERED_NO_ REMINDER = N | RESET = N |  EXPIRED = N }

Header string template

(Optional) Defines the first line of the output, usually column headings. Can be a combination of literal text and the $headings$ variable.

Example header templateOutputNotes
Name,ID,LTR Name,ID,LTRLiteral text.
$headings$ e_Namee_unitIDq_ltrKeynames; no separator.
$headings; separator=","$ e_Name,e_unitID,q_ltr“,” separator.
$headings; separator="|"$ e_Name|e_unitID|q_ltr“|” separator.
$headings:{$it.key$}$ e_Namee_unitIDq_ltrKeynames.
$headings:{$it.name$}$ Full NameUnit IDCustomer LTRShort names.
$headings:{$it.name$}; separator="|"$ Full Name|Unit ID|Customer LTRShort name; “|” separator.
[$headings; separator=","$] [e_Name,e_unitID,q_ltr]Mix literal and variable.

Body string template

(Required) Defines the format of the record values; one row per record. This definition must include the $cells$ variable, and may include literal text before or after the cells.

Example body templateOutputNotes
$cells$ Mikeu0077Field values; no separator.
$cells; separator=","$ Mike,u007,7Comma separator.
$cells; separator="|"$ Mike|u007|7“|” separator.
- $cells; separator=","$ - Mike,u007,7Mix literal and cells.