Entity saved successfully but still showing "Save operation failed ok"

432 views Asked by At

Basically, I have an AddEdit screen (loaded from a browse screen) from which am saving an entity. On clicking on the save Icon, the entity was actually saved but am still getting a "save operation failed Ok" message popping up which was preventing the browse screen from refreshing the table consisting the saved entity list.

Seemingly, a change is not getting persisted or something.

1

There are 1 answers

0
Vitali Donghvani On

Add/Edit screen validates data before insert/update.

If you update existing record which has DateTime column (Example: registration DateTime, record creation DateTime and etc.) in it and if you use LightSwitch's dateTime picker control there might be a validation error.

LightSwitch's dateTime picker can not read some DateTime formats therefore can't assign value (which came from DB) to control. Usually it shows the validation error which is good, however if you set control visibility to false you will never see the error caused by hidden control.

Error gets ignored in most of the browsers except of IE.

It is kind of bug.

Solution is to temporarily show all hidden controls on the screen and check insert/update functionality. You will see the error and control which caused that error.

You can change control type to Text or Edit or assign value to it manually (below code).

You can write your own method to insert/update record. Have a look the following code:

myapp.BrowseProducts.EditProduct_execute = function (screen) {    
    myapp.showAddEditProduct(null, {
        beforeShown: function (editNewProductScreen) {
           var selectedProduct = screen.products.selectedItem;            
           editNewProductScreen.product= selectedProduct;
        },
        afterClosed: function () {
           screen.products.refresh();
        }
    });
};

add refresh in "afterClosed" function which solves the data refresh problem.