5/5

reject(): clean a phone list before a text campaign

Hard

Before a text-message campaign goes out, the phone list has to be cleaned. Everything not removed stays, in its original order.

Remove

  • entries that are blank or missing
  • numbers on the do-not-contact list
  • test numbers, which all start with "+1555"

Watch out

  • A number that only contains 555 later on, like "+14155551234", is a real customer.
  • Each test needs the number in a different slot: startswith() takes the text first, contains() takes the list first. Mark the slot with an underscore.

Inputs

  • ri!numbers — List of Text
  • ri!doNotContact — List of Text, never empty

ri! Rule Inputs

ri!numbersList of Text
{
  "+14155550100",
  "",
  "+15551234567",
  null,
  "+14155550199",
  "+12125550123"
}
ri!doNotContactList of Text
{"+14155550199"}

Example 1 — A messy import

Input: ri!numbers
{
  "+14155550100",
  "",
  "+15551234567",
  null,
  "+14155550199",
  "+12125550123"
}
Input: ri!doNotContact
{"+14155550199"}
Output:
{
  "+14155550100",
  "+12125550123"
}

Example 2 — 555 later in the number is a real customer

Input: ri!numbers
{"+14155551234"}
Input: ri!doNotContact
{"+10000000000"}
Output:
{"+14155551234"}

Example 3 — Several on the do-not-contact list

Input: ri!numbers
{
  "+12125550123",
  "+13125550100",
  "+16175550111"
}
Input: ri!doNotContact
{
  "+16175550111",
  "+12125550123"
}
Output:
{"+13125550100"}

Example 4 — Nothing left to send

Input: ri!numbers
{
  "",
  null,
  "+15550000000"
}
Input: ri!doNotContact
{"+10000000000"}
Output:
{}

Example 5 — No numbers

Input: ri!numbers
{}
Input: ri!doNotContact
{"+10000000000"}
Output:
{}

Appian Expression Tips

  • • Use ri!variableName for 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