On a custom save button that renders if the model has unsaved changes, if you make some changes, save them, then make more changes, the button doesn’t show up again like it should. Somehow it’s not detecting that there are unsaved changes after saving changes once.
My save button does the following actions:
- block UI and show message
- save model changes (Opportunity)
- query model (Opportunity)
- unblock the UI
a little background in case that helps point to where I went wrong:
I built custom save and cancel buttons to run multiple actions, because I wanted to re-query my model after saving. Honestly I can’t remember why at the moment, I think there were some cases where changing a field changed other values that didn’t show up unless the model was queried again.
If you have a Save button that is a Run Multiple Actions button then you can always click it, even if there are no changes to save. This is annoying, so I created a Render Condition that hides the button if there are no unsaved changes in the model.
This is a big page with over 20 models and a dozen tabs. Originally I had one Save button on my page title above the tab set, but it was taking forever to save because it had to save and requery all the models, plus the render condition had to take into account unsaved changes on any of my models.
So, I added another page title inside each tab to hold the save and cancel buttons. I could just focus on the models on that page for save/query/check for unsaved changes. This also helped get the buttons closer to where users were actually making changes.
I’ve got a third page title on the bottom of the page outside of the tabset. Eventually I want to bring this into the tab set and add more save/cancel buttons, because I like it when users don’t have to move their mouse too far.