REST – Retrieve Multiple Example

Retrieve Multiple

Syntax: SDK.REST.retrieveMultipleRecords(type, options, successCallback, errorCallback, OnComplete)

Name Type Description
type String The Schema Name of the Entity type record to retrieve.
options String A String that represents the OData System Query Options to control the data returned.
successCallback Function The function that will be passed through and be called for each page of records returned.
This example uses the retrieveContactsCallBack function.
errorCallback Function The function that will be passed through and be called by a failed response.
This example uses the errorCallBack function.
OnComplete Function The function that will be called when all the requested records have been returned.
This example uses the contactsRetrieveComplete function.

Task:  Retrieve all Contacts contains MobilePhone data
Solution: Add the below Script in “new_sdkOperations” Webresource and click Ok.

Please do check REST – Retrieve for Initial Setup.

function retrieveMultipleContacts() {
var options = "$select=FullName,MobilePhone&$filter=MobilePhone ne null"; //Write your own Query to get Records
SDK.REST.retrieveMultipleRecords("Contact", options, retrieveContactsCallBack, errorCallBack, contactsRetrieveComplete);
}

function retrieveContactsCallBack(retrievedContacts) {
var outputString = "";
outputString = "FullName\t\t\tMobile Phone\n";
outputString = outputString + "--------------------------------------------------\n";
for (var i = 0; i < retrievedContacts.length; i++) {
outputString = outputString + retrievedContacts[i].FullName + " \t " + retrievedContacts[i].MobilePhone + "\n";
}
alert(outputString);
}

function errorCallBack(error) {
alert(error.message);
}

// This function is called after all the records have been returned
function contactsRetrieveComplete() {
}

Add OnLoad event in Contact Form, Library: new_sdkOperations & function retrieveMultipleContacts. Save and Publish

Image

Output:
Open any Contact Record to see the below output,

Image

Please provide your valuable comments on this article.

Advertisements