Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

Error in plugin in CRM 2013

$
0
0

I'm getting the following error in a plugin in CRM 2013: Incorrect attribute value type System.Int32

The error is occuring in the following piece of code:

private void UpdateEnquiry(ITracingService tracingService, IOrganizationService service, DateTime date, Guid EnquiryId)
        {
            // Create an update request. 
            try
            {
                Entity entity = new Entity("new_enquiry");
                entity.Id = EnquiryId;
                tracingService.Trace("date: " + date);
                if (date > DateTime.MinValue)
                {
                    entity.Attributes["new_lastcustomersupplieddate"] = ConvertToLocalTime(service, date);
                    tracingService.Trace("entity.Attributes[new_lastcustomersupplieddate]: " + entity.Attributes["new_lastcustomersupplieddate"].ToString());
                    entity.Attributes["new_status"] = EnquiryStatus.Interim;
                    tracingService.Trace("entity.Attributes[new_status]: " + entity.Attributes["new_status"].ToString());
                }
                else
                {
                    entity.Attributes["new_lastcustomersupplieddate"] = null;
                    tracingService.Trace("entity.Attributes[new_lastcustomersupplieddate]: " + entity.Attributes["new_lastcustomersupplieddate"].ToString());
                    entity.Attributes["new_status"] = EnquiryStatus.Pending;
                    tracingService.Trace("entity.Attributes[new_status]: " + entity.Attributes["new_status"].ToString());
                }
                UpdateRequest updateRequest = new UpdateRequest();
                tracingService.Trace("Updating entity");
                updateRequest.Target = entity;
                UpdateResponse updateResponse = (UpdateResponse)service.Execute(updateRequest);
                tracingService.Trace("updateResponse: " + updateResponse);
                throw new InvalidPluginExecutionException();
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException("Error in UpdateEnquiry " +ex.ToString());
            }
            finally
            {
            }

        }
The tracingService lines are my attempt to debug the plugin. They all appear in the log file, except the final one after the (UpdateResponse)service.Execute(updateRequest); line.

Here's the full error from the log file, with the results of the tracing service lines:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Error in Execute Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Error in UpdateEnquiry System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect attribute value type System.Int32 (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).
   at VS.CA.CRM.CustomerContactDate.SetLastSuppliedDate.UpdateEnquiry(ITracingService tracingService, IOrganizationService service, DateTime date, Guid EnquiryId)
   at VS.CA.CRM.CustomerContactDate.SetLastSuppliedDate.Execute(IServiceProvider serviceProvider)Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220891</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <d2p1:key>OperationStatus</d2p1:key>
      <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <d2p1:key>SubErrorCode</d2p1:key>
      <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>Error in Execute Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Error in UpdateEnquiry System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect attribute value type System.Int32 (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).
   at VS.CA.CRM.CustomerContactDate.SetLastSuppliedDate.UpdateEnquiry(ITracingService tracingService, IOrganizationService service, DateTime date, Guid EnquiryId)
   at VS.CA.CRM.CustomerContactDate.SetLastSuppliedDate.Execute(IServiceProvider serviceProvider)</Message>
  <Timestamp>2014-02-28T10:54:54.7594262Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>

[VS.CA.CRM.CustomerContactDate: VS.CA.CRM.CustomerContactDate.SetLastSuppliedDate]
[5912b703-3f28-e211-8c0a-3c4a92dbd8ab: VS.CA.CRM.CustomerContactDate.SetLastSuppliedDate: Update of new_customercontactdates]


date: 2/27/2014 12:00:00 AM
entity.Attributes[new_lastcustomersupplieddate]: 2/27/2014 1:00:00 AM
entity.Attributes[new_status]: 2
Updating entity


</TraceText>
</OrganizationServiceFault>

 


Viewing all articles
Browse latest Browse all 1000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>