Unsaved warning: what is the root cause

I have a master detail order entry UI where I have used the option to create multiple sales orders without returning to the browser screen. It works well except in one my screens it is returning a message.

While I click on the OK button, I get the attached warning (attached file : warning save.PNG) as if i called cancell button instead. What could be the reason?
I didn’t see any error message and not sure which code would be helpful to share for diagnosis.

Here is the xml file code related to windowActions

        <hbox id="buttonsBox"
            <button id="createNewBtn"
                    caption="Save and create new"
            <frame id="windowActions"

Thanks in advance for any help.

ok option

warning save

Further update. I have a table for file upload in the same user interface. When upload a file, I don’t get that unsaved alert message. Therefore it seems to be the message is coming from file upload mechanism that I have used. But not sure what is causing this alert!

Here is my file upload code that i have put in postInit

        multiUploadField.addQueueUploadCompleteListener(() -> {
            for (Map.Entry<UUID, String> entry : multiUploadField.getUploadsMap().entrySet()) {
                UUID fileId = entry.getKey();
                String fileName = entry.getValue();
                FileDescriptor fd = fileUploadingAPI.getFileDescriptor(fileId, fileName);

                try {
                    fileUploadingAPI.putFileIntoStorage(fileId, fd);
                } catch (FileStorageException e) {
                    new RuntimeException("Error saving file to FileStorage", e);


                SalesOrderAttachment attachment = metadata.create(SalesOrderAttachment.class);

            showNotification("Uploaded files: " + multiUploadField.getUploadsMap().values(), NotificationType.HUMANIZED);

Hi Mortoza,

The reason can be as follows:

  • After you press OK, all changed entities are sent to the middleware, and saved instances are returned to the screen and are set to the same datasources. It happens even right before closing the screen.

  • If you have any calculations in datasource listeners (like calculating an Order amount by OrderLines), they can be invoked because datasource listeners are fired.

  • These calculations can change the entities again comparing to the saved instances set in the datasources.

An example of such case can be found here:

private void calculateAmount() {
    BigDecimal amount = BigDecimal.ZERO;
    for (OrderLine line : linesDs.getItems()) {
        amount = amount.add(line.getProduct().getPrice().multiply(line.getQuantity()));
    getItem().setAmount(amount.setScale(2, RoundingMode.HALF_UP)); // (!)

If you remove the line marked with (!), the calculation will change the instance because the scale of BigDecimal will differ from the scale of this attribute in the database. So a good practice when working with BigDecimal is to set it’s scale to the same value as defined for the database column.