Current filter:
                                You should refresh the page.
                                  • Steps to reproduce
                                    run demo project
                                    go to orders list view
                                    click Show Problem
                                    then double click new order line item to enter line item detail view
                                    http://www.screencast.com/t/QIBUGNOSPx

                                    UPDATED by Dennis (DevExpress Support):

                                    11.01.17 08:20:22.130        Type: DevExpress.ExpressApp.Actions.SimpleAction  
                                                                    ID: ListViewShowObject  
                                                                    Category: ListView  
                                                                    Controller.Name: DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController  
                                                                    Context.Name: Lines  
                                                                    Context.IsRoot: False  
                                                                    Context.SelectedObjects.Count: 1  
                                                                    Context.CurrentObject: System.Data.Entity.DynamicProxies.SalesManifestLine_FA244D61C4CB1CB35ED7232263324ADD4FA89C4A37D51CBDD89CB937A897DAA1  
                                      
                                    11.01.17 08:20:23.976    ================================================================================  
                                    The error occurred:  
                                      
                                        Type:       UserFriendlyException  
                                        Message:    An error with number 1057 has occurred.  
                                    Error message: A newly created record cannot be shown until it is saved. Please save it to view its details in a separate form.  
                                        Data:       0 entries  
                                        Stack trace:  
                                      
                                       at DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController.ShowObject(Object obj, ShowViewParameters showViewParameters, XafApplication application, Frame sourceFrame, View sourceView)  
                                       at DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController.ProcessCurrentObject(SimpleActionExecuteEventArgs e)  
                                       at DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController.processCurrentObjectAction_OnExecute(Object sender, SimpleActionExecuteEventArgs e)  
                                       at DevExpress.ExpressApp.Actions.SimpleAction.RaiseExecute(ActionBaseEventArgs eventArgs)  
                                       at DevExpress.ExpressApp.Actions.ActionBase.ExecuteCore(Delegate handler, ActionBaseEventArgs eventArgs)  
                                        InnerException is null  
                                    

                                1 Solution

                                Creation Date Importance Sort by

                                Hi Kirsten,

                                This behavior is by design. You create an object using an ObjectSpace and try to open it in a DetailView. The DetailView uses its own instance of an ObjectSpace and this ObjectSpace has no access to the object because it wasn't committed to a database. If you want to edit this object, you can either commit the object or use inline editing.

                                Show all comments
                                • kirsten greed 01.11.2017

                                  Thanks Serge.
                                  If the Order object is created by clicking New on the ListView then I can drill into the detail record without receiving this error.

                                  I would like to be able to have this same behaviour when my "New Like" action is used.

                                  Can you advise how I can achieve this?

                                • Serge K (DevExpress) 01.12.2017

                                  Hi Kirsten,

                                  Can you describe why you can't save objects before opening it in a Detail View? It can be done in the ShowProblem() method by calling the ObjectSpace.CommitChanges method.

                                  You can achieve your goal by manually creating a Detail View for the non-committed object. This Detail View should use the same ObjectSpace with the Detail View of the newly created Order object. The default Detail View can be replaced with the one manually created using the ListViewProcessCurrentObjectController.CustomProcessSelectedItem event.The following controller demonstrated this approach:

                                  [C#]
                                  using DevExpress.ExpressApp; using DevExpress.ExpressApp.SystemModule; using T469497.Module.BusinessObjects; namespace T469497.Module.Controllers { public class CustomProcessObjectViewController : ViewController<ListView> { ListViewProcessCurrentObjectController processCurrentObjectController; public CustomProcessObjectViewController() { TargetViewNesting = Nesting.Nested; TargetObjectType = typeof(OrderLine); } protected override void OnActivated() { base.OnActivated(); processCurrentObjectController = Frame.GetController<ListViewProcessCurrentObjectController>(); if(processCurrentObjectController != null) { processCurrentObjectController.CustomProcessSelectedItem += originalController_CustomProcessSelectedItem; } } protected override void OnDeactivated() { base.OnDeactivated(); if(processCurrentObjectController != null) { processCurrentObjectController.CustomProcessSelectedItem -= originalController_CustomProcessSelectedItem; } } void originalController_CustomProcessSelectedItem(object sender, CustomProcessListViewSelectedItemEventArgs e) {             if(ObjectSpace.IsNewObject(e.InnerArgs.CurrentObject)) {                 e.Handled = true;                 e.InnerArgs.ShowViewParameters.CreatedView = Application.CreateDetailView(ObjectSpace, e.InnerArgs.CurrentObject, false);             } } } }

                                  The manually created Detail View should be a non-root View to share the ObjectSpace. So this Detail View will not have Save and Cancel actions. You can't rollback your changes if you modify the object opened in this Detail View.

                                • kirsten greed 01.12.2017

                                  Hi Serge
                                  The reason I don't want to save the new object prior to showing it in the view is that "New Like" should behave just like "New" except that the data values should default to a copy of the current record.

                                • Serge K (DevExpress) 01.12.2017

                                  Hi Kirsten,

                                  Thank you for the clarification. Does the solution provided above meet your requirements?

                                • kirsten greed 01.14.2017

                                  Thanks Serge
                                  I ran into the problem I logged at T472010 , So I will come back to this issue once I understand how to fix that one.

                                • Serge K (DevExpress) 01.15.2017

                                  I'm looking forward to hearing from you.

                                • kirsten greed 01.16.2017

                                  Hi Serge
                                  Can you give me an example of how I am meant to cause originalController_CustomProcessSelectedItemto execute ?

                                • kirsten greed 01.16.2017
                                • Serge K (DevExpress) 01.17.2017

                                  Hi Kirsten,

                                  The ListViewProcessCurrentObjectController.CustomProcessSelectedItem event fires when you open a DetailView of any object from a ListView. For example, the event will fire when you double-click any record in the ListView. This event allows you to customize the default DetailView or replace it with custom one. The default DetailView uses its own ObjectSpace to access its current object. The ViewController I attached above replaces the default DetailView with a custom DetialView. This custom DetailView has the ObjectSpace that was used to create a new uncommitted object. So, the custom DetailView can read and update this newly created uncommitted object.

                                • kirsten greed 01.17.2017

                                  It only seems to fire if I double click a line item in a nested list view. It does not fire when I enter the detail view by clicking the add button

                                • Serge K (DevExpress) 01.18.2017

                                  Hi Kirsten,
                                  It's not clear to me what "add button" you mean. Can you describe the desired behavior in greater detail? I'm looking forward to hearing from you.

                                • kirsten greed 01.19.2017

                                  Hi Serge, you did help me with the original answer.  If I want to follow up the further discussion I will add a new question that is better thought out.