where(): flag the messages that cannot be sent
Medium
Before a text-message campaign goes out, the editor highlights every draft that cannot be sent: one longer than ri!limit characters, or one left completely empty.
Return the positions of those drafts, in order.
Watch out
where()takes any list of Booleans, so build that list one draft at a time when the test combines two conditions.or()given two whole lists answers once for everything, not once per draft.
Inputs
ri!messages— List of Textri!limit— Integer
ri! Rule Inputs
ri!messagesList of Text{
"Sale ends tonight",
"",
"Big news"
}ri!limitInteger12
Example 1 — One too long, one empty
Input: ri!messages
{
"Sale ends tonight",
"",
"Big news"
}Input: ri!limit
12
Output:
{
1,
2
}Example 2 — Exactly at the limit is fine
Input: ri!messages
{"Twelve chars"}Input: ri!limit
12
Output:
{}Example 3 — Everything can be sent
Input: ri!messages
{
"Hi",
"See you"
}Input: ri!limit
20
Output:
{}Example 4 — Every draft is a problem
Input: ri!messages
{
"",
"This one is far too long"
}Input: ri!limit
5
Output:
{
1,
2
}Example 5 — No drafts
Input: ri!messages
{}Input: ri!limit
10
Output:
{}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