Quantcast
Viewing all articles
Browse latest Browse all 79901

Plugin throwing exception Object reference not found in Dynamics CRM 2011

I've developed a-sync plugin for updating some fields. But it gives me exception. I've tried using tracing and I found everything is fine.

Following is my code:

itService.Trace("new_approve:"+entity.Attributes["new_approve"]);
                    if (entity.Attributes.Contains("new_approve"))
                    {
                        toApprove = (bool)entity.Attributes["new_approve"];
                        if (toApprove == true)
                        {
                            itService.Trace("Checking if it contians guid");
                            if (entity.Attributes.Contains("new_contactsguids"))
                            {
                                itService.Trace("Guid:" + entity.Attributes["new_contactsguids"]);
                                listGuids = (string)entity.Attributes["new_contactsguids"];
                                arrGuids = listGuids.Split(',');

                                foreach (var guid in arrGuids)
                                {
                                    visitation.Attributes["new_2015agencyvisitationchecklistid"] = new Guid(guid);
                                    visitation.Attributes["new_checkliststatus"] = option;
                                    visitation.Attributes["new_approvedbydistrictmanager"] = true;
                                    service.Update(visitation);

                                }   
                            }
                        }
                    }


And here is the Exception:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): approveCheckLists.approveListts: System.NullReferenceException: Object reference not set to an instance of an object.Detail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
  <ErrorCode>-2147220956</ErrorCode>
  <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
  <Message>Unexpected exception from plug-in (Execute): approveCheckLists.approveListts: System.NullReferenceException: Object reference not set to an instance of an object.</Message>
  <Timestamp>2015-08-14T11:40:16.4580628Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>

[approveCheckLists: approveCheckLists.approveListts]
[3be16d74-7742-e511-8aa3-005056b04acd: approveCheckLists.approveListts: Create of new_requestforapproval]

About to checking entity and its type
Checking if entity contains new_approve
new_approve:True
Checking if it contians guid
Guid:{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx},{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx}
</TraceText>
</OrganizationServiceFault>



Viewing all articles
Browse latest Browse all 79901

Trending Articles



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