MobileCRM.FetchXml.Fetch.execute - Resconet/JSBridge GitHub Wiki

Performs the asynchronous CRM Fetch request.

Arguments

Argument Type Description
output String A string defining the output format: Array, JSON, XML or DynamicEntities.
success function(result) A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by output argument.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set "null" to call the callbacks in global scope.

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.execute("Array", // Take the results as an array of arrays with field values
function (result) {
	// "result" is
	// [["A Bike Store","52A239BD-E8F9-425C-B3A4-FD685D659215"],
	// ["All Cycles","0FDBF212-4F72-4019-A9B6-59F0695EB646"],...];
	for (var i in result) {
		// "account" is ["A Bike Store","52A239BD-E8F9-425C-B3A4-FD685D659215"]
		var account = result[i];
		// Pass accountid and name for processing
		processAccount(account[0], account[1]);
	}
}, function (err) {
	MobileCRM.bridge.alert("Error fetching accounts: " + err);
}, null);
⚠️ **GitHub.com Fallback** ⚠️