reject(): drop internal accounts from a report
Medium
Before the monthly usage report goes out, internal accounts have to come off the list: every username that starts with "test_" or "demo_". Everyone else stays, in their original order.
Watch out
startswith()needs the username and the prefix. Mark the slot the username goes into with an underscore and fix the prefix.- Starting with a prefix is not the same as containing it:
"contest_winner"is a real customer.
Input
ri!usernames— List of Text
ri! Rule Inputs
ri!usernamesList of Text{
"ann",
"test_1",
"bo",
"demo_x"
}Example 1 — Both kinds of internal account
Input: ri!usernames
{
"ann",
"test_1",
"bo",
"demo_x"
}Output:
{
"ann",
"bo"
}Example 2 — Containing is not starting with
Input: ri!usernames
{
"contest_winner",
"ann"
}Output:
{
"contest_winner",
"ann"
}Example 3 — Only internal accounts
Input: ri!usernames
{
"test_a",
"demo_b"
}Output:
{}Example 4 — No accounts
Input: ri!usernames
{}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