Answered by:
Problem to save a particular record CRM2011

Question
-
Hi,
I am facing problems while trying to save a new record onto CRM. Strangely, this only happens for a particular entity. I have tested many other entities and they all are able to store data but this one in particular does not. I usually receive a Null Reference Exception but when I debug it, I can see that the object is still instantiated.
What makes CRM trigger such exception?
Regards,
DemersonTuesday, December 16, 2014 12:28 AM
Answers
-
Hi Everyone,
Just letting you all know that I have fixed the problem. For some reason the dev server was corrupted somewhere. Only one entity had problem to save new records, so I ended up creating a backup from the production server and just updating the database from the dev server. I believe that also brought configs that fixed the error. I am now able to save new records anywhere.
Thanks for all answers and if anyone experiences the same problem I will be happy to help.
Regards,
Demerson- Marked as answer by Donna EdwardsMVP Thursday, January 8, 2015 4:25 PM
Monday, December 22, 2014 3:20 AM
All replies
-
Hi,
There can be many reasons for this.
Can you give more details as to how you are trying to create the record i.e. through CRM screen, plugin, Workflow?
Is there any plugin registered on create, or any javascript on save?
Does the user have write permission for that entity?
Is it a custom entity or OOB entity?
Pasting the error you are getting would be helpful!!
Hope this helps!!!
Thanks,
Prasad
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.
Tuesday, December 16, 2014 4:46 AM -
Hi Prasad,
Thanks for your reply.
I was first trying to create the record using an application which I am developing but after receiving so many errors I have decided trying to use CRM screen (web) to test and it turns out to not be working. When I click on the button save, nothing happens. I checked the javascript to make sure that the onsave was ok but it is still not saving. When I hit the button without validating the form, then errors pop up on the screen, but when I fill in the fields appropriately and try to save, no action is taken. Then, I try running a simple code which basically just inserts a new record and a null reference exception is trigged.
Below exception:
Microsoft.Xrm.Sdk.SaveChangesException was unhandled by user code HResult=-2146233088 Message=An error occured while processing this request. Source=Microsoft.Xrm.Sdk StackTrace: at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges(SaveChangesOptions options) at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges() at TimesheetSample.Controllers.TimesheetController.SaveTimesheetLine(TimesheetViewModel timesheetLineVm) in c:\Users\Demerson.Herculano\Documents\AES Projects\TimesheetSample\TimesheetSample\Controllers\TimesheetController.cs:line 161 at TimesheetSample.Controllers.TimesheetController.New(TimesheetViewModel timesheetVm) in c:\Users\Demerson.Herculano\Documents\AES Projects\TimesheetSample\TimesheetSample\Controllers\TimesheetController.cs:line 110 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() InnerException: System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> HResult=-2146233087 Message=System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #FB5F14A6 Source=mscorlib Action=http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/ExecuteOrganizationServiceFaultFault StackTrace: Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChange(OrganizationRequest request, IList`1 results) InnerException:
This is my class:
private static void Start() { // first we get the connectionstring from app.config string connectionString = ConfigurationManager.ConnectionStrings["CRM"].ConnectionString; // we connect to crm using the simplified connection CrmConnection crmConnection = CrmConnection.Parse(connectionString); IOrganizationService service = new OrganizationService(crmConnection); // we get the ID of the current user (in this way we test the connection WhoAmIRequest whoAmIRequest = new WhoAmIRequest(); WhoAmIResponse whoAmIResponse = (WhoAmIResponse)service.Execute(whoAmIRequest); Console.WriteLine("Connected with UserID: " + whoAmIResponse.UserId.ToString()); // we create the timesheet New_timesheet timesheet = new New_timesheet(); timesheet.New_FirstName = "TESTING"; timesheet.New_LastName = "CRM"; // other fields here // timesheetId will contain the Guid of the timesheet Guid timesheetId = Guid.Empty; try { timesheetId = service.Create(timesheet); } catch (Exception ex) { Console.WriteLine("Error creating the timesheet: " + ex.Message); Environment.Exit(0); // we close the application } Console.WriteLine("Timesheet created."); // now we create a line New_timesheetlineitem line1 = new New_timesheetlineitem(); line1.new_timesheettimesheetlineitemid = new EntityReference(New_timesheet.EntityLogicalName, timesheetId); // reference to the timesheet line1.New_TimesheetDate = DateTime.Now; line1.New_SubmittedHours = 3m; // 3m means 3 in decimal notation Guid line1Id = Guid.Empty; try { line1Id = service.Create(line1); } catch (Exception ex) { Console.WriteLine("Error creating the line1: " + ex.Message); Environment.Exit(0); // we close the application } Console.WriteLine("Line1 created."); }
Wednesday, December 17, 2014 1:45 AM -
Hi Everyone,
Just letting you all know that I have fixed the problem. For some reason the dev server was corrupted somewhere. Only one entity had problem to save new records, so I ended up creating a backup from the production server and just updating the database from the dev server. I believe that also brought configs that fixed the error. I am now able to save new records anywhere.
Thanks for all answers and if anyone experiences the same problem I will be happy to help.
Regards,
Demerson- Marked as answer by Donna EdwardsMVP Thursday, January 8, 2015 4:25 PM
Monday, December 22, 2014 3:20 AM