Zombie tabs
At least two places in our system we experience zombie tabs, tabs that after an error message are impossible to close.
I can now reproduce the issue: We have a custom "Delivery Risks" tab on parts. If I add a new risk and open it, the UI thinks the object is in a dirty state. Just opening it and closing it again, I get a popup with "Changes have not been saved. What do you want to do?". If I select "save" here, I get the error
at T0 (factory.ts:152:8)
at Object.execute (factory.ts:169:24)
at onUnlockCommand (include.aspx?classes=tearoffWindow:915:36)
at async eval (eval at x0 (factory.ts:53:9), <anonymous>:30:10)
at async T0 (factory.ts:140:10)
I can avoid creating a zombie tab by clicking "Edit" and "Save" manually in the form. Even though there are no changes, that apparently syncs the state properly.
Requesting the object with AML studio, newly created items in potential zombie state look exactly like ones which have been edited and saved, so the problem isn't in the database end. Fully logging out and logging in again also clears potential zombie state, but merely closing the Part does not. So it's some kind of Item cache in the frontend which thinks the Risk object is dirty - or possibly it's the Form Item which is dirty.
This is Aras 31 by the way.
It makes sense that the behavior appears in the context of a dialog. This is very similar to the post I mentioned before.
In the shown use case dirty items aren´t a big problem as the dialog is mainly executed from released items. In my case I reset the "isDirty" attribute to 0 inside the dialog callback function. This is important when user close the dialog without doing anything. Things get more complicated for item that can still be edited.
Quote: "checks if the item is dirty and saves it if it is"
That´s one approach that I also use sometimes! You can even execute the save action automatically in silent mode to avoid to distract the user. As alternative, you can of course just tell the user to save first by themselves. This is an actual code sample that I use when I don´t want use the silent mode. Use case is an automatically sort_order renumbering function that user can use while working with the relationships:
// Don´t renumber if item is dirty (=unsaved changes)
const isDirty = window.aras.isDirtyEx(contextItem.node);
if (isDirty)
{
return aras.AlertError("Blablabla please save first....");
}I am not sure if this is the official recommended way to deal with dirty items. But I have seen similar solutions in the OOTB Innovator code.