Skip to content

MobileCRM.FetchXml.Fetch.executeAsync

rescocrm edited this page May 15, 2023 · 9 revisions

Performs the asynchronous CRM Fetch request.

Arguments

Argument Type Description
output String A string defining the output format: Array, JSON, XML or DynamicEntities.
online Boolean Optional parameter determining whether the fetch should be executed online or offline. If omitted, function respects current online/offline mode of the app.

This example demonstrates how to fetch a list of accounts and process their names.

var entity = new MobileCRM.FetchXml.Entity("account");
entity.addAttribute("accountid");
entity.addAttribute("name");
var fetch = new MobileCRM.FetchXml.Fetch(entity);
fetch.executeAsync(null) // "null" stands for default "DynamicEntities" result format
	.then(function (result) {
	// Promise was fulfilled and we obtained an array of DynamicEntities
	for (var i in result) {
		var account = result[i];
		// Pass account id and name for further processing
		processAccount(account.id, account.primaryName);
	}
})
	.catch(function (err) {
	// Promise was rejected with error
	MobileCRM.bridge.alert("Error fetching accounts: " + err);
});
Clone this wiki locally