Mobile SDK - Android › Mobile SDK API reference › API reference › API implementation and reference
Filter class- Android
The Filter class provides the ability to configure filters that define the data to return in the return results of a REST endpoint query.
| Name | Type | Description |
|---|
| queryItems | Map<String, String> | Collection of query items representing the filter. |
Parent Topic:Mobile SDK - Android
Filter - Filter(conditions: List<Condition>, keywords: String? = null, sortBy: List<Sort>? = null)
Creates a filter based on specific keywords and conditions that can be OR'd or AND'd together.
| Name | Type | Description |
|---|
| conditions | List<Condition> | Simple or compound conditions to add to the query.Possible conditions: - BooleanSimpleCondition: Conditions available for boolean record fields. - DateSimpleTimeCondition: Conditions available for date-time record fields. - EmailSimpleCondition: Conditions available for email fields. - IntegerChoiceSimpleCondition: Conditions available for integer choice fields. - NumericSimpleCondition: Conditions available for various numeric fields. - ReferenceSimpleCondition: Condition operators available for reference record fields. - StringChoiceSimpleCondition: Condition operators available for choice record fields containing strings. - StringSimpleCondition: Condition operators available for string record fields. - CompoundCondition: Allows you to group SimpleConditions into a compound condition using ConditionUtils.CompoundOperator connectors. |
| keywords | String | Optional. Any specific word or phrase to search for.Default: nil - No specific word search. |
| sortBy | List<Sort> | Optional. List of record field names and the associated sort order constant to sort the returned records by. For example: `val sortBy = listOf("zipcode", ORDER_DESC)`If you include multiple sort fields, each subsequent field is a further sort of the prior field\(s\). Valid sort values: - ORDER\_ASC: Sort ascending - ORDER\_DESC: Sort descending Default: ORDER\_ASC |
// Where the record is active
val condition1 = BooleanSimpleCondition.conditionIs("active", true)
// AND the date value of the SLA due field is on "today" or any date after today.
val condition2 = DateSimpleTimeCondition.atOrAfter("sla_due", 0, ConditionUtils.DateTimeValueOperator.daysAgoStart)
val filter = Filter(conditions = listOf(condition1, condition2))
Filter - Filter(criteriaList: List<Criteria>, sortBy: List<Sort>? = null)
Creates a filter based on one or more filter criteria that are OR'd together.
| Name | Type | Description |
|---|
| criteriaList | List<Criteria> | Top level criteria conditions to group with `OR` connectors. |
| sortBy | List<Sort> | Optional. List of record field names and the associated sort order constant to sort the returned records by. For example: `val sortBy = listOf("zipcode", ORDER_DESC)`If you include multiple sort fields, each subsequent field is a further sort of the prior field\(s\). Valid sort values: - ORDER\_ASC: Sort ascending - ORDER\_DESC: Sort descending Default: ORDER\_ASC |
val activeIncidents = BooleanSimpleCondition.conditionIs("active", true)
val assignedToEmpty = StringSimpleCondition.isEmpty("assigned_to")
val assignedToAbel = StringSimpleCondition.conditionIs("assigned_to", "Abel Tuter")
val assignedToAbelOrEmpty = CompoundCondition(ConditionUtils.CompoundOperator.OR, listOf(assignedToEmpty, assignedToAbel))
val needToReassign = Criteria().addConditions(listOf(activeIncidents, assignedToAbelOrEmpty))
val highEscelations = StringSimpleCondition.conditionIs("escalation", "2")
val overdueEscelations = StringSimpleCondition.conditionIs("escalation", "3")
val highOrOverdueEscelations = CompoundCondition(ConditionUtils.CompoundOperator.OR, listOf(highEscelations, overdueEscelations))
val needToHandleEscalation = Criteria().addCondition(highOrOverdueEscelations)
val myPrioritiesForTodayFilter = Filter(listOf(needToReassign, needToHandleEscalation))