a!queryRecordType( recordType, fields, filters, pagingInfo, fetchTotalCount )
Executes a query on a given record type and returns the result.
See also: Record Type, DataSubset, Constructing Data Type Values, Aggregation Fields Function
Keyword | Type | Description |
---|---|---|
|
RecordType |
A reference to a record type. You must reference the record type directly from the |
|
Any Type |
Fields to be retrieved for the query. This parameter accepts different values depending on the type of query to run. When performing a selection, use a list of record field or related record field references defined with the |
|
Any Type |
A single logical expression or a list of query filters can be provided to apply additional filters to the record set. Queries also inherit the default filters defined on the referenced record type. Reference record fields or related record fields from the specified record type using the |
|
PagingInfo |
The paging and sorting configurations to apply when retrieving the record data. |
|
Boolean |
If set to |
There are two methods of returning data using a!queryRecordType
:
fields
parameter.The return type of a!queryRecordType
will be a Map data type with the following parameters:
success
(Boolean)data
(List of Record Maps or List of Maps)startIndex
(Integer)batchSize
(Integer)sort
(List of SortInfo)totalCount
(Integer)identifiers
(List of Integer or List of Text)errorCode
(Text)This map will have the same named fields as a DataSubset (so that it can seamlessly be cast to that type when being passed around your application) with the addition of "success" and "errorCode" fields, like results from an Integration object, so app developers can build error-handling into their applications.
The type for the data parameter varies depending on the type of query:
You can refine the function's output by using dot notation (.) to access specific fields. To have the expression return just the queried data, add .data
to the end of the a!queryRecordType()
function. Then, to access the data contained in a particular field, add the field name with a record field reference: data[recordType!<record type name>.fields.<field name>]
a!queryRecordType
returns a query result even if a runtime error happened. In these cases the "success" field of the result would have a value of false and the "errorCode" field will return an Appian Error Code indicating what has happened. You can use these codes to decide what to do next in your application.
Error Code | Description | Usage |
---|---|---|
APNX-1-4205-038 | The user does not have access to this record type, a related record type, or the underlying data source. This also applies if the user does not have access to a referenced related record type in a filter, sort, or aggregation. | This error code could be used to hide elements of an interface |
APNX-1-4205-039 | The record type or a related record type has not been synced, or the existing synced data has been invalidated. | This error code could be used as a condition on which to query the data source instead of waiting for the sync issue to be resolved. |
APNX-1-4205-040 | The record type's data source or the related record type's data source could not be reached, or the query limit for that source has been reached. | While uncommon, for finicky data sources, this error code could be used to prevent an interface from breaking. |
recordType!
domain to reference a record field. For example, recordType!Customer.fields.firstName
returns the firstName
field from the Customer record type.recordType!
domain to reference a relationship and select a related record field.
recordType!Customer.relationships.cases.fields.status
is using the relationship on the Customer record type to select the status
field from the Case record type.a!queryRecordType
cannot be larger than 5000
, and cannot be -1
.sortInfos
are not yet available for process-backed record types.Record type object references are specific to each environment. If you copy and paste these examples into your interface, they will not evaluate. Use them as a references only.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
a!queryRecordType(
recordType: recordType!Customer,
fields: {
recordType!Customer.fields.name,
recordType!Customer.fields.customerSince,
recordType!Customer.relationships.industry.fields.label
},
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 5000,
sort: {
a!sortInfo(
field: recordType!Customer.fields.customerSince,
ascending: false
),
a!sortInfo(
field: recordType!Customer.fields.name,
ascending: true
)
}
),
fetchTotalCount: true
).data
Sample output from the query above:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
a!queryRecordType(
recordType: recordType!Order,
fields: a!aggregationFields(
groupings: a!grouping(
field: recordType!Order.relationships.priority.fields.label,
alias: "Priority",
),
measures: a!measure(
field: recordType!Order.fields.id,
function: "COUNT",
alias: "Order_Count"
)
),
filters: a!queryFilter(
field: recordType!Order.fields.createdOn,
operator: "between",
value: /* Trailing 12 Months */ {eomonth(today(),-13) + 1, eomonth(today(),-1)}
),
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500,)
).data
Sample output from the query above:
There are older versions of this function. You can identify older versions by looking at the name to see if there is a version suffix. If you are using an old version, be sure to refer to the corresponding documentation from the list below.
Old Versions | Reason for Update |
---|---|
a!queryRecordType_20r4 | Replaced selection with fields, which now allows for both selection and aggregation of record data when querying a given record type. |
To learn more about how Appian handles this kind of versioning, see the Function and Component Versions page.