split(): count the fields on a line
Easy
Return how many comma-separated fields ri!line has, counting empty ones.
Two commas together mean a field that is there but blank, and it counts.
Empty text is a line with one field, not zero.
Input
ri!line: Text
ri! Rule Inputs
ri!lineText"a,b,c"
Example 1: Three fields
Input: ri!line
"a,b,c"
Expected output:
3
Example 2: One field, no commas
Input: ri!line
"a"
Expected output:
1
Example 3: A blank field in the middle counts
Input: ri!line
"a,b,,c"
Expected output:
4
Example 4: Empty text is one field, not none
Input: ri!line
""
Expected output:
1
Example 5: A trailing comma adds a field
Input: ri!line
"a,b,"
Expected output:
3
Appian Expression Tips
- • Use
ri!variableNamefor rule inputs - • Use
a!localVariables(local!x: …, body)for locals - • Use
a!forEach(items: …, expression: fv!item)to iterate - • Use
where()/reject(fn!isnull, list)to filter