You are given a custom list of maps in Appian, where each map contains fields like name and id. Some of the name values are either null or empty strings. How would you remove the entries that have a null or empty name field using Appian expressions?
Input:
{ a!map(id: 1, name: "AppianVerse"), a!map(id: 2, name: "Appian"), a!map(id: 3, name: null()), a!map(id: 4, name: "Java"), a!map(id: 5, name: null()), a!map(id: 6, name: "flutter"), a!map(id: 7, name: ""), a!map(id: 8, name: "") }Output:
{a!map(id: 1, name: "AppianVerse"), a!map(id: 2, name: "Appian"), a!map(id: 4, name: "Java"), a!map(id: 6, name: "flutter")}
You are given a custom list of maps in Appian, where each map contains fields like name and id. Some of the name values are either null or empty strings. How would you remove the entries that have a null or empty name field using Appian expressions?
Input:
Output:
{a!map(id: 1, name: "AppianVerse"), a!map(id: 2, name: "Appian"), a!map(id: 4, name: "Java"), a!map(id: 6, name: "flutter")}
Answer
In Appian, you can remove employee records with a null or empty name by looping over the list with a!forEach(), checking each name with a!isNotNullOrEmpty(), and dropping the leftover nulls with reject(). The records that remain keep all of their other fields.
Code:
Explanation:
This expression filters a list of employee records by checking whether each name is null or empty. It uses a!forEach() to evaluate each record and reject(fn!isnull, ...) to remove the leftover values from the resulting list.
local!dataholds a list of employee records, each with anidand aname. Some records have a null or empty name.a!forEach()loops over the records, andfv!itemis the current record.a!isNotNullOrEmpty(fv!item.name)checks whether the current name has a value.- If it does, the expression returns the whole record. Otherwise, it returns an empty string (
""). reject(fn!isnull, ...)removes the null values from the resulting list, which leaves the records that have a name.
Output:

Return records in Appian which has empty or null in given list of map
Some times interview might ask to returns id's which has name as empty or null. We can use where() to identify indexes in the map and return those records. Below the code
Code:
Output:
Explanation:
1. Define the data local!data is a list of eight maps. Records 3 and 5 have a null() name, records 7 and 8 have an empty string, and the rest have real names.
2. Check every record with a!forEach()
a!forEach() visits each record, and fv!item.name is the current record’s name. a!isNullOrEmpty() returns true when the name is null or empty and false otherwise, so one check covers both null() and "".
The result is one true/false value per record:
3. Turn the true values into positions with where()
where() takes a list of true/false values and returns the positions of the true ones. Here those are 3, 5, 7, and 8:
Position | Record | Name empty or null? |
|---|---|---|
1 | id 1 | false |
2 | id 2 | false |
3 | id 3 | true |
4 | id 4 | false |
5 | id 5 | true |
6 | id 6 | false |
7 | id 7 | true |
8 | id 8 | true |
4. Pull out those records with index()
index() returns the items at the given positions. The third argument is the value to return if a position doesn’t exist, which here is an empty list. The result is the four records at positions 3, 5, 7, and 8.
Getting only the ids
If the interviewer asks for the ids and not the whole records, loop over the matches and take the id field:
This returns {3, 5, 7, 8}.
Try it yourself
Change the inputs or the expression and run it to see what it returns.
Independent evaluator: it approximates the Appian expression language and may differ from a real Appian environment. Verify anything that matters. Terms