Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Dynamics 365 ExportToExcel Action returns "Failed to Generate Excel." (-2147088185)

$
0
0

Performing 'ExportToExcel', using javascript is fails with 'Failed to generate excel.'

I am trying to export 'My Account' view output, using the latest Dynamics 365, version 9.

Any suggestions or advice is greatly welcomed.

Process.callAction("ExportToExcel",
[{
key: "View",
type: Process.Type.EntityReference,
value: new Process.EntityReference("SavedQuery", viewGuid)
},
{
key: "FetchXml",
type: Process.Type.String,
value: fetchxml
},
{
key: "LayoutXml",
type: Process.Type.String,
value: layoutxml
},
{
key: "QueryApi",
type: Process.Type.String,
value: " "
},
{
key: "QueryParameters",
type: "InputArgumentCollection",
value: []
}],

....
Error follows
s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="en-US">Failed to generate excel.</faultstring>
<detail>
<OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance">
<ActivityId>f5b9a7b9-d1e2-4a3d-9269-58a3545df818</ActivityId>
<ErrorCode>-2147088185</ErrorCode>
<ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/>
<Message>Failed to generate excel.</Message>
<Timestamp>2017-11-01T02:32:20.0787607Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true"/>
<InnerFault>
<ActivityId>f5b9a7b9-d1e2-4a3d-9269-58a3545df818</ActivityId>
<ErrorCode>-2147088185</ErrorCode>
<ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/>
<Message>Failed to generate excel.</Message>
<Timestamp>2017-11-01T02:32:20.0787607Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true"/>
<InnerFault i:nil="true"/>
<OriginalException i:nil="true"/>
<TraceText i:nil="true"/>
</InnerFault>
<OriginalException i:nil="true"/>
<TraceText i:nil="true"/>
</OrganizationServiceFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>

The following .NET code works successfully as a console application. Unfortunately, it won't run in the Dynamics 365 online sand-boxed plug-in 

var exportToExcelRequest = new OrganizationRequest("ExportToExcel");
exportToExcelRequest.Parameters = new ParameterCollection();
//Has to be a savedquery aka "System View" or userquery aka "Saved View"
//The view has to exist, otherwise will error out
exportToExcelRequest.Parameters.Add(new KeyValuePair<string, object>("View", new EntityReference("savedquery", new Guid("{00000000-0000-0000-00AA-000010001001}"))));
exportToExcelRequest.Parameters.Add(new KeyValuePair<string, object>("FetchXml", @"<fetch version='1.0' output-format='xml-platform' mapping='logical'><entity name='account'><attribute name='name' /><attribute name='address1_city' /><order attribute='name' descending='false' /><filter type='and'><condition attribute='ownerid' operator='eq-userid' /><condition attribute='statecode' operator='eq' value='0' /></filter><attribute name='primarycontactid' /><attribute name='telephone1' /><attribute name='accountid' /><link-entity alias='accountprimarycontactidcontactcontactid' name='contact' from='contactid' to='primarycontactid' link-type='outer' visible='false'><attribute name='emailaddress1' /></link-entity></entity></fetch>"));
exportToExcelRequest.Parameters.Add(new KeyValuePair<string, object>("LayoutXml", @"<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'><row name='result' id='accountid'><cell name='name' width='300' /><cell name='telephone1' width='100' /><cell name='address1_city' width='100' /><cell name='primarycontactid' width='150' /><cell name='accountprimarycontactidcontactcontactid.emailaddress1' width='150' disableSorting='1' /></row></grid>"));
//need these params to keep org service happy
exportToExcelRequest.Parameters.Add(new KeyValuePair<string, object>("QueryApi", ""));
exportToExcelRequest.Parameters.Add(new KeyValuePair<string, object>("QueryParameters", new InputArgumentCollection()));

string result = WriteFromObject(exportToExcelRequest.Parameters);

var exportToExcelResponse = sourceCrm.Service.Execute(exportToExcelRequest);
if (exportToExcelResponse.Results.Any())
{
}

Cheers,
Mark


Viewing all articles
Browse latest Browse all 46379

Trending Articles