var
relatedContact = [];
function
onloadFetchAllContactRecords(){
var
serverUrl = Xrm.Page.context.getServerUrl();
var
oDataUrl = serverUrl +
quot;/xrmservices/2011/OrganizationData.svc/ContactSet?$select=EMailAddress1,FirstName,LastName$filter=StateCode/Value eq 0quot;
;
GetContactRecords(oDataUrl);
var
totalRecords = relatedContact.length;
}
function
GetContactRecords(url){
jQuery.ajax({
type:
quot;GETquot;
,
contentType:
quot;application/json; charset=utf-8quot;
,
datatype:
quot;jsonquot;
,
url: url,
async:
false
,
beforeSend:
function
(XMLHttpRequest){
XMLHttpRequest.setRequestHeader(
quot;Acceptquot;
,
quot;application/jsonquot;
);
},
success:
function
(data, textStatus, XmlHttpRequest){
if
(data data.d !=
null
data.d.results !=
null
){
var
objrecord = data.d;
var
records = objrecord.results;
insertRecordsToArray(records);
FetchRecordsCallBack(objrecord);
}
},
error:
function
(XmlHttpRequest, textStatus, errorThrown){
alert(
quot;An error has occurredquot;
);
}
});
}
function
insertRecordsToArray(records){
for
(
var
i = 0; i < records.length; i++){
relatedContact.push(records[i]);
}
}
function
FetchRecordsCallBack(objrecord){
if
(objrecord.__next !=
null
){
var
url = objrecord.__next;
GetContactRecords(url);
}
}
Hope this helps.