locked
MS dynamcis crm 2011 - Delete record from a custom entity error RRS feed

  • Question

  • Hi,

    Would like to ask help why i can't delete a record from a custom entity i have created. Error message shows:

    

    below is the content of the downloaded log file:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #F6A1AF01Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220970</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      <Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #F6A1AF01</Message>
      <Timestamp>2013-11-07T05:38:29.1708266Z</Timestamp>
      <InnerFault>
        <ErrorCode>-2147220891</ErrorCode>
        <ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
        <Message>(Exception) UsageAndExpensePlug-inThe given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Microsoft.Xrm.Sdk.Entity.get_Item(String attributeName)
       at NexusPluginLibrary.UsageAndExpense.Execute(IServiceProvider serviceProvider)
    </Message>
        <Timestamp>2013-11-07T05:38:29.1708266Z</Timestamp>
        <InnerFault i:nil="true" />
        <TraceText>

    [NexusPluginLibrary: NexusPluginLibrary.UsageAndExpense]
    [c1b73b66-3315-e311-87d1-36d7c49cdbe8: NexusPluginLibrary.UsageAndExpense: Update of nexus_usageandexpenses]


    </TraceText>
      </InnerFault>
      <TraceText i:nil="true" />
    </OrganizationServiceFault>

    I appreciate any prompt response.

    thank you and regards,

    Honey

    Thursday, November 7, 2013 6:01 AM

Answers

  • It seems there is a delete message plugin running on the same entity, which is causing the problem.

    Please try to debug your code and error related to reading values from entity object but inside object there is no key exist.

    So, you need to write like as below :

    If(Entity.Attributes.Contains("fieldname")
    {
    string Val=Entity.Attributes["fieldname"].toString();
    }



    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
    Vikram !


    • Edited by _Vikram Thursday, November 7, 2013 6:26 AM
    • Marked as answer by Honey Dulatre Wednesday, August 13, 2014 6:19 AM
    Thursday, November 7, 2013 6:25 AM

All replies

  • Do you have any plugins registered on this entity. The error is coming from the plugin.
    Thursday, November 7, 2013 6:07 AM
  • It seems there is a delete message plugin running on the same entity, which is causing the problem.

    Please try to debug your code and error related to reading values from entity object but inside object there is no key exist.

    So, you need to write like as below :

    If(Entity.Attributes.Contains("fieldname")
    {
    string Val=Entity.Attributes["fieldname"].toString();
    }



    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
    Vikram !


    • Edited by _Vikram Thursday, November 7, 2013 6:26 AM
    • Marked as answer by Honey Dulatre Wednesday, August 13, 2014 6:19 AM
    Thursday, November 7, 2013 6:25 AM
  • hi,

    the usageandexpense plugin is for another entity. plug-in incorporated with this record is named budgetandnonbudgetedexpense plug-in. this error appears in the Budget and Non-Budgeted entity. Meanwhile i have another entity named Usage and expense. When a record has been created in Usage and expense entity,  the user must select the related budget and non-budgeted expense. earlier i was experiencing an error when saving the usage and expense record. Upon saving a plugin will start to retrieve all field values from the related budget and non-budgeted expense and display to the usage and expense form. Unfortunately when i saved the record, though there is an existing budget record an error prompts saying that no record has been fetch. i think this scenario is related to the issue i raised. afterwards i tried to delete the budget record and i can't delete it. 

    Please advise how to troubleshoot on this.

    thanks and regards,

     honey

    Thursday, November 7, 2013 6:41 AM
  • Please try to debug your plugin.

    http://rajeevpentyala.wordpress.com/2012/01/13/debugging-plug-ins-in-crm/

    http://guruprasadcrm.blogspot.com/2011/11/how-to-debug-crm-2011-online-plugin.html


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
    Vikram !

    Thursday, November 7, 2013 6:45 AM
  • The error message specifically refers to the UsageAndExpense plugin. I expect this is called because you have a cascading operation on the relationship between the entity you're trying to delete and the entity that has this plugin. A workaround might be to change the cascading rules, but the fundamental problem is that the plugin is poorly coded, and should be fixed to work in this scenario

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Thursday, November 7, 2013 8:13 AM
    Moderator