I am trying to access the custom entity object by this way:
Entity visitation = new Entity("new_2015agencyvisitationchecklist");
But this gives me nothing in it ans also I an exception while updating it. Following is the code that I'm using for upating:
visitation.Id = new Guid(guid);
visitation["new_checkliststatus"] = option.Value;
visitation["new_approvedbydistrictmanager"] = true;
service.Update(visitation);
Following is the exception details:
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>