getItems( )
Returns the selected items.
Description
The getItems()
function returns a Promise that is resolved to
a GetItemsResult
object when the items have been
retrieved.
Calling getItems()
on a write-only dataset causes an error.
Note:
A dataset needs to load its data before you call its
getItems()
function. Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you callgetItems()
inside the page’sonReady()
event handler, the dataset might not be ready yet.To call
getItems()
as soon as possible after a page loads, use the dataset'sonReady()
function inside the page’sonReady()
event handler to ensure that both the page and the dataset have finished loading.
Syntax
function getItems(fromIndex: number, numberOfItems: number): Promise<GetItemsResult>
getItems Parameters
NAME
TYPE
DESCRIPTION
The index of the first item to return.
The number of items to return.
Returns
Fulfilled - The items retrieved and the total number of items in the dataset that match its filter criteria. Rejected - An error object.
Return Type:
NAME
TYPE
DESCRIPTION
List of items objects where key:value pairs are the field IDs and field values of the retrieved items, including all hidden fields.
The number of items in the dataset that match its filter criteria.
The index in the dataset of the first item in the items property.
Related Content:
Was this helpful?
1$w("#myDataset").getItems(3, 2)2 .then( (result) => {3 let items = result.items;4 let totalCount = result.totalCount;5 let offset = result.offset;6 } )7 .catch( (err) => {8 let errMsg = err.message;9 let errCode = err.code;10 } );
1$w.onReady( () => {2 $w("#myDataset").onReady( () => {3 $w("#myDataset").getItems(3, 2)4 .then( (result) => {5 let items = result.items;6 let totalCount = result.totalCount;7 let offset = result.offset;8 } )9 .catch( (err) => {10 let errMsg = err.message;11 let errCode = err.code;12 } );1314 } );1516} );