rbf_getViewPage()
Purpose
This function fetches a set of records in a view, including (optionally) dependent records and allows you to apply a filter to the results. It brings info back to the page using an asynchronous AJAX mechanism. The amount of processing and time required to get complete results can vary widely, depending on whether it fetches related records and the number of rows you specify per page.
For pages containing fields that allow values in multiple languages,
you can use the options parameter to specify the
language in which to return the values. If the values are not available in the
specified language, it will return the values for the tenant's base language. If the
specified language is not configured for the tenant, it will throw an error.
Syntax
rbf_getViewPage(viewId, callback,
options);
Parameters
viewId
The original ID of the view.
callback
A callback function that will receive an array of fetched records as first parameter.
options
An optional JSON object that sets the values of optional arguments. The properties that this object can take are as follows:
- startRow: The row to start fetching records from (0 by default).
- rowsPerPage: The maximum number of row to fetch in one call (user-specified value by default).
- composite: The
option to retrieve related records.
- level: The depth of recursion of dependent records (0 by default).
- objects: An array of objects where each element
has two mandatory attributes – objName and fieldList. There must be a valid value for
objects if level >0.
- objName: A valid integration name of a related object. (null and * are not valid values).
- fieldList: A comma-separated list of field names to fetch for corresponding objects. You can provide different fieldList for different related objects as part of composite. This fieldList is independent of the view object fieldList. (null and * are not valid values).
- fieldList: A comma-separated list of field names to fetch (use "*" for all fields - default value).
- useLegacyDateFormat: If
true, or if not specified, a date value is returned as a Date object. Iffalse, a date value is returned as a String. - filtering: The filters to be applied
on the
view.
"filtering": { "dateFilter": [{ "field": "<integration_name_of_field>", "value": "<valid_date_filter_operand>" }], "filters": [{ "field": "<integration_name_of_field>", "opCode": "<valid_opCode_for_field_type>", "value": "<value>" }, { /* Additional filters */ }], "joinType": "OR|AND" }Note: ThedateFiltersis an array type and only one date filter is supported in this API. ThedateFilteris not counted into the MaxFilters limit. - sorting: The sorting to be applied on the
view.
"sorting": [{ "field": "<integration_name_of_field>", "order": "asc(default)|desc" }, { "field": "<integration_name_of_field>", "order": "asc(default)|desc" }, { "field": "<integration_name_of_field>", "order": "asc(default)|desc" }] - langCode: A valid two-letter ISO language code,
for example,
{"langCode":"es"}. useISODateFormatto get the date or date/time values in ISO format, for example,{"useISODateFormat":true}.- If the date and time value is
Mon Jul 30 00:01:00 IST 2018its equivalent ISO formatted value2018-07-29T18:31:00Z-is returned. - If the date value is
Mon Jul 30 2018, its equivalent ISO formatted value2018-07-30is returned.
- If the date and time value is
If there are filters mentioned in the view definition page, the joinType is derived from the view definition page and
it ignores the joinType (if any) specified on the
API call.
If there are no filters defined in the view definition page, the joinType is
derived from the API call. So, it is mandatory to specify the
joinType in such a case.
- The total number of allowed filters (including those defined
in the view definition) cannot exceed the shared property
MaxFilters(default value 5). When sorting is specified on the API call, it overrides any sort settings on the view definition. Only 3 sort levels are allowed on the API call. - If both useLegacyDateFormat and useISODateFormat are set to
true, useISODateFormat is applied.
Special date filter can be specified like the one available in UI. The 'name' should be the integration name of the date field. The possible value that a filter value takes is as follows.
| Date Filter Value: UI | Date Filter Value: API |
|---|---|
| Current year | YEAR|YEAR+1 |
| Previous year | YEAR-1|YEAR |
| Current and previous yea | YEAR-1|YEAR+1 |
| Next year | YEAR+1|YEAR+2 |
| Current quarter | QUARTER|QUARTER+1 |
| Previous quarter | QUARTER-1|QUARTER |
| Current and previous quarter | QUARTER-1|QUARTER+1 |
| Next quarter | QUARTER+1|QUARTER+2 |
| Current month | MONTH|MONTH+1 |
| Last month | MONTH-1|MONTH |
| Current and previous month | MONTH-1|MONTH+1 |
| Next month | MONTH+1|MONTH+2 |
| Current and next month | MONTH|MONTH+2 |
| This week | WEEK|WEEK+1 |
| Last week | WEEK-1|WEEK |
| Next week | WEEK+1|WEEK+2 |
| Today | TODAY|TODAY+1 |
| Yesterday | TODAY-1|TODAY |
| Tomorrow | TODAY+1|TODAY+2 |
| Last 7 days | TODAY-7|TODAY |
| Last 30 days | TODAY-30|TODAY |
| Last 60 days | TODAY-60|TODAY |
| Last 90 days | TODAY-90|TODAY |
| Next 30 days | TODAY+1|TODAY+30 |
The following table lists the different values that an opCode key can take for field types derived from UI.
| opCode Key | Value |
|---|---|
| EQ | equals |
| NEQ | not equal |
| ST | starts with |
| CT | contains |
| END | ends with |
| NCT | does not contain |
| LT | less than |
| GT | greater than |
| LE | less or equal |
| GE | greater or equal |
| IN | in array |
| NIN | not in array |
| CH | checked |
| NCH | unchecked |
| INC | including |
| NINC | not including |
| NUL | is null |
| NNUL | not null |
| IS | is |
The following table lists the opCode keys that are available for different field types.
| Field Types | opCode Keys |
|---|---|
| Picklist, Role, Status, Process, Appraisal, Approval | EQ, NEQ, IN, NIN |
| Relationship, User, Portal Visitor | EQ, NEQ, IN, NUL, NNUL |
| Multi-picklist | INC, NINC |
| Number (Integer, etc), Date | EQ, NEQ, LT, GT, LE, GE, NUL, NNUL |
| Time | LT, GT, LE, GE, NUL, NNUL |
| Checkbox | CH, NCH |
| Text | EQ, NEQ, ST, END, CT, NCT, IN, NIN, NUL, NNUL |
| File | NUL, NNUL |
Note: This API is supported in portals as well.
Example
The following example filters columns by amount, price, and DOB:
rbf_getViewPage("12345", my_callback, {
"useLegacyDateFormat": false,
"startRow": 0,
"rowsPerPage": 1000,
"composite": {
"level": 1,
"objects": [{
"objName": "order",
"fieldList": "amount"
}]
},
"fieldList": "amount, price,DOB",
"filtering": {
"dateFilter": [{
"field": "DOB",
"value": "WEEK-1|WEEK"
}],
"filters": [{
"field": "amount",
"value": "1606",
"opCode": "GE"
},
{
"field": "price",
"value": "102",
"opCode": "EQ"
}
],
"joinType": "OR"
},
"sorting": [{
"field": "amount",
"order": "asc"
},
{
"field": "price",
"order": "desc"
}
],
"langCode": "es"
});