Current filter:
                                You should refresh the page.
                                  • Hello,
                                    I am getting the following error using the Schedule control.
                                    "An error with number 1057 has occurred. Error message: An unsaved object cannot be shown ."
                                    the error shows when the parent domain object is not saved first. I am trying to auto save using the autocommit mode within a view controler.

                                    the following video capture demonstrates the error.
                                    https://dl.dropboxusercontent.com/u/9944011/TBXScheduleError4-7-2014%204-51-32%20PM.mp4

                                    What I want to do is simply auto save the schedule record but am unable to find a way to do this.

                                • Erin Gray 04.07.2014

                                  //this is the view controller I am using
                                  using System;
                                  using System.Linq;
                                  using System.Collections.Generic;
                                  using DevExpress.ExpressApp;
                                  using DevExpress.ExpressApp.Win.SystemModule;
                                  namespace TimeAndBillingXAF.Module.Win.Controllers
                                  {
                                      // For more typical usage scenarios, be sure to check out http://documentation.devexpress.com/#Xaf/clsDevExpressExpressAppViewControllertopic.
                                      public partial class vcSchedule : ViewController
                                      {

                                          public vcSchedule()
                                          {
                                              InitializeComponent();
                                              RegisterActions(components);
                                              // Target required Views (via the TargetXXX properties) and create their Actions.
                                          }
                                          private WinModificationsController worker;

                                          protected override void OnActivated()
                                          {
                                              base.OnActivated();
                                              ObjectSpace.ObjectChanged += ObjectSpace_ObjectChanged;
                                              //if (ObjectSpace.IsNewObject(View.CurrentObject))
                                              //{
                                                  worker = Frame.GetController<WinModificationsController>();

                                                  worker.ModificationsHandlingMode = DevExpress.ExpressApp.SystemModule.ModificationsHandlingMode.AutoCommit;
                                              //}
                                          }
                                          protected override void OnDeactivated()
                                          {
                                              ObjectSpace.ObjectChanged -= ObjectSpace_ObjectChanged;
                                              worker = null;
                                              base.OnDeactivated();
                                          }
                                          private void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e)
                                          {
                                              if (worker != null)
                                              {
                                                  worker.ModificationsHandlingMode = DevExpress.ExpressApp.SystemModule.ModificationsHandlingMode.AutoCommit;
                                              }
                                          }
                                          protected override void OnViewControlsCreated()
                                          {
                                              base.OnViewControlsCreated();
                                              // Access and customize the target View control.
                                          }

                                      }
                                  }

                                2 Solutions

                                Creation Date Importance Sort by

                                Dennis, You are a genuine hero!
                                I combined your advice from both of your posts and now have a controller that allows a user to auto save the record before navigating to the detail view.
                                Much Thanks for the help!

                                The code is as follows:

                                using System;using System.Linq;using System.Collections.Generic;using DevExpress.ExpressApp;using DevExpress.ExpressApp.SystemModule;

                                namespace TBX.Module.Win.Controllers{ public partial class vcSchedule : ViewController {
                                public vcSchedule() { InitializeComponent(); RegisterActions(components); } private ListViewProcessCurrentObjectController processCurrentObjectController;
                                protected override void OnActivated() { base.OnActivated(); processCurrentObjectController = Frame.GetController<ListViewProcessCurrentObjectController>(); if (processCurrentObjectController != null) { processCurrentObjectController.CustomProcessSelectedItem += processCurrentObjectController_CustomProcessSelectedItem; }
                                }
                                private void processCurrentObjectController_CustomProcessSelectedItem(object sender, CustomProcessListViewSelectedItemEventArgs e) { e.Handled = true; Open.DoExecute(); }
                                protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); // Access and customize the target View control. }
                                private void Open_Execute(object sender, DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs e) { View.ObjectSpace.CommitChanges(); ListViewProcessCurrentObjectController.ShowObject(e.CurrentObject, e.ShowViewParameters, Application, Frame, View); }

                                }}

                                • Erin Gray 04.09.2014

                                  using System;
                                  using System.Linq;
                                  using System.Collections.Generic;
                                  using DevExpress.ExpressApp;
                                  using DevExpress.ExpressApp.SystemModule;
                                  namespace TBX.Module.Win.Controllers
                                  {

                                      public partial class vcSchedule : ViewController
                                      {
                                          public vcSchedule()
                                          {
                                              InitializeComponent();
                                              RegisterActions(components);
                                          }

                                          private ListViewProcessCurrentObjectController processCurrentObjectController;
                                          protected override void OnActivated()
                                          {
                                              base.OnActivated();
                                              processCurrentObjectController =
                                              Frame.GetController<ListViewProcessCurrentObjectController>();
                                              if (processCurrentObjectController != null)
                                              {
                                                  processCurrentObjectController.CustomProcessSelectedItem += processCurrentObjectController_CustomProcessSelectedItem;
                                              }
                                          }
                                          private void processCurrentObjectController_CustomProcessSelectedItem(object sender, CustomProcessListViewSelectedItemEventArgs e)
                                          {
                                              e.Handled = true;
                                              Open.DoExecute();

                                          }
                                          protected override void OnViewControlsCreated()
                                          {
                                              base.OnViewControlsCreated();
                                              // Access and customize the target View control.
                                          }
                                          private void Open_Execute(object sender, DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs e)
                                          {
                                              View.ObjectSpace.CommitChanges();
                                              ListViewProcessCurrentObjectController.ShowObject(e.CurrentObject, e.ShowViewParameters, Application, Frame, View);
                                          }

                                      }
                                  }

                                • Dennis (DevExpress Support) 04.10.2014

                                  I am glad to hear of your progress, Robert.

                                Hello Robert,
                                It is strange that you are trying to change the ModificationsHandlingMode option in the ObjectChanged event handler. It is sufficient to set it only once when еру Controller is activated.
                                If you need to commit the changes, manually call the View.ObjectSpace.CommitChanges method:

                                [C#]
                                private void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e) { if (worker != null) { View.ObjectSpace.CommitChanges(); //worker.ModificationsHandlingMode = DevExpress.ExpressApp.SystemModule.ModificationsHandlingMode.AutoCommit; } }

                                We will also consider improving the current behavior to avoid execution of the default Action for a new and unsaved object. For instance, here a confirmation message to save the new record can be displayed to the user.

                                • Erin Gray 04.08.2014

                                  Dennis,
                                  Thanks for the response.
                                  I may be a little closer but am still not getting the desired results.
                                  Once I implemented the View.ObjectSpace.CommitChanges(); to the ObjectChanges Event handler it looks like the code is attempting to commit changes however when I add of move something to the schedule control the control is not given the chance to update the end date before the commitchanges method is fired. What is happening now is that a validation error is now popping up anytime changes are made on the schedule control indicating that the start date is less than the end date.
                                  Is there anything else that I can try?
                                  Thanks in advance.

                                • Dennis (DevExpress Support) 04.09.2014

                                  Thanks for your update.
                                  Committing data causes data validation as expected. If you do not want automatic data commit, then you can implement different logic as your business requirements dictate. My goal was to just show that it is required to commit data to open a newly created record.
                                  For instance, you can show a confirmation message to a user when a new record is being shown. To do this, handle the CustomProcessSelectedItem event of the ListViewProcessCurrentObjectController.