ACD201 practice question 2 of 15

You're designing an expression rule that needs to retrieve employees from a database for a given department and display their full name concatenated with their role in a list for a dropdown field. Which design approach should you recommend?

Full set: 99 questions
Answer options
A: Query the data to return all employees. Using a!forEach(), for each item in the list, if the employee belongs to the given department, return the employee name and role, otherwise, return a null value.
B: Query the data to return all employees. Use wherecontains() to return the employees for the given department and use a!forEach() to return the employee name and role for each item in the list.
C: Query the data with a filter applied to only return employees for the given department. Using a!forEach(), for each item in the list, return the employee name and role. Correct answer
Correct Answer:
C. Query the data with a filter applied to only return employees for the given department. Using a!forEach(), for each item in the list, return the employee name and role.
Explanation

This approach is the most performant and scalable design. By applying a filter directly within the data query (e.g., using the filter parameter in a!queryRecordType), the database performs the filtering, leveraging its indexing and optimization capabilities. This significantly reduces the amount of data transferred over the network and loaded into Appian's memory. The a!forEach() function is then used efficiently on the smaller, pre-filtered dataset to format the results for the dropdown, which is a standard Appian best practice.

Why Incorrect

A. This is highly inefficient. Retrieving all employees into memory to filter them using an if() condition inside a loop creates unnecessary server load and is not scalable for large datasets.
B. This is also inefficient. While wherecontains() is a valid function, it operates on data already loaded into Appian's memory. Fetching the entire table from the database first is a performance anti-pattern.

References

1. Official Appian Documentation

Performance Best Practices

"Data Queries" section: "Filter and sort in the database whenever possible. The database is optimized for operating on large sets of data

so you should let it do the heavy lifting." This directly supports filtering at the source (Option C) and refutes retrieving all data first (Options A and B).

Source: Appian Documentation

"Performance Best Practices".

2. Official Appian Documentation

a!queryRecordType() function

"Parameters" section: The documentation for the filter parameter states its purpose is to filter the data returned by the query. This is the mechanism that enables the efficient approach described in Option C.

Source: Appian Documentation

"a!queryRecordType()".

3. Official Appian Documentation

Query Recipes

"Return a List of Records" section: Examples demonstrate the standard pattern of using a!queryRecordType with an a!queryFilter to retrieve a specific subset of data

followed by data manipulation if needed. This aligns perfectly with the methodology in Option C.

Source: Appian Documentation

"Query Recipes".

Scroll to Top