Docs / Mapper Text Lists
Split packed text into lists
When a partner packs several lot codes or references into one text field, use split(text, separator) to make those values available to the collection functions.
Choose a literal separator
toJson(split("LOT-A,LOT-B", ","))
// ["LOT-A","LOT-B"]
toJson(split("A||B||", "||"))
// ["A","B",""]
The separator must be a nonempty string. It is matched literally, including characters such as ., |, and *; it is not a regular expression. Multi-character separators are supported. Text before the first separator and after the last separator is retained.
The input can be a string or a list containing exactly one string or X12 element. For example, split(ST->BEG(03), "-") splits the purchase order number. X12 elements use their original text, retaining leading zeros and decimal formatting. The result is a new, mutable list of strings.
Preserve empty fields and whitespace
toJson(split(",A,,B,", ","))
// ["","A","","B",""]
toJson(split("", ","))
// [""]
toJson(trim(split("LOT-A, LOT-B", ",")))
// ["LOT-A","LOT-B"]
Leading, trailing, and consecutive separators produce empty fields. An empty string produces one empty field; text without the separator produces one unchanged field. Splitting does not trim whitespace or remove duplicates. Apply trim or a collection filter explicitly when those transformations are appropriate.
An empty selection is different from an empty text value. Guard optional data before splitting it, or supply a fallback such as split(firstNonEmpty(ST->N1?(02), ""), ",").
Combine values from several fields
packedLots = ["LOT-A, LOT-B", "LOT-A"]
lots = set(flatMap(text in packedLots => trim(split(text, ","))))
toJson(lots)
// ["LOT-A","LOT-B"]
flatMap combines each field's split results into one list; set removes duplicates while retaining the first occurrence. Use forEach(text in packedLots => split(text, ",")) when each field should keep its own nested list. Passing several fields directly to split reports an error instead of choosing a result shape implicitly.
The resulting values work with the other collection helpers:
values = split("B,A,B", ",")
print(join(orderBy(value in set(values) => value), "|"))
// A|B
Resolve input errors
E4801: The input is not text or a single text/X12 element. For example,split(123, ",")fails; usesplit("123", ",")for text.E4802: An input list or element selection contains zero or multiple values. Forsplit(["A,B","C,D"], ","), useflatMaporforEachto split each value explicitly.E4803: The separator is empty or is not a string. Replacesplit("A,B", "")withsplit("A,B", ",").E3205: The input is a segment selection. Select an element, such asST->BEG(03), instead of passingST->BEG.
The Mapper Built-ins reference contains the complete signature and examples. Save representative packed values as mapping test cases to preserve your partner's delimiter and empty-field rules.