-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.MobileReport.runReport
rescocrm edited this page May 15, 2023
·
10 revisions
[v9.1] Executes the mobile reporting request which produces the mobile report document of given format.
Argument | Type | Description |
---|---|---|
fetch | String | The fetch XML defining the entity (entities) query used as report input. |
reportXML | String | The mobile report XML definition which can be loaded from the resco_report entity or constructed dynamically. Ignored if IsExportOnly parameter is true. |
reportFormat | String | Report format: Pdf (default), Html, Excel, Text. |
isExportOnly | Boolean | If true then ReportXml is optional. The default is false. |
isOnline | Boolean | Indicates whether the report should be run against the online data or local database. The default is current application mode. |
outputFile | String | The full path to the output file. If omitted a temp file is created. The output path is always passed to the success callback. |
success | function(obj) | A callback function that is called with the file path to successfully created report. |
failed | function(errorMsg) | A callback which is called in case of error. |
scope | Object | The scope for callbacks. |
This example demonstrates how to create a mobile report document of specific format.
function fetchReportXML() {
var report = new MobileCRM.FetchXml.Entity("resco_mobilereport");
report.addAttribute("resco_data");
var fetch = new MobileCRM.FetchXml.Fetch(report);
fetch.execute("Array", function (res) {
/// <param name='res' type='Array'>Array of results carrying resco_data field value.</param>
if (res.length > 0) {
var reportXML = res[0][0];
runMobileReport(reportXML);
}
}, MobileCRM.bridge.alert, null);
}
// Alternatively, you can run your own custom mobile report definition.
// Assumes that 'salesorder' entity have 'totalamount' and 'name' attributes enabled.
function runMobileReport(reportXML) {
var fetchXML = "<fetch version='1.0' count='1' resultformat='Array' mapping='logical' distinct='true'><entity name='salesorder'><attribute name='discountamount' /><attribute name='totalamount' /><attribute name='name' /></entity></fetch>";
MobileCRM.Configuration.requestObject(function (config) {
/// <param name='config' type='MobileCRM.Configuration'/>
var filePath = config.storageDirectory + "/MyCustomReport.pdf"; // Create file in storage directory.
MobileCRM.MobileReport.runReport(fetchXML, reportXML, "Pdf", null, false, filePath, function (res) {
/// in success callback, report form with data and fetch should be displayed.
}, MobileCRM.bridge.alert);
}, MobileCRM.bridge.alert, null);
}