Skip to main content

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

Is there some reason that this would cause future changes to not show up as unsaved changes?


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.

You should only have to requery a model after saving if it’s a value that changes in another model.

If some of those values changed on the record affected other records values, then it would be appropriate to requery them. These can be updated by many many things:
- workflow
- flow
- process builder
- approval process
- formula field
- roll up field

Here’s  what I’d do.
- use the standard Save/Cancel button in the Title Page
- set Model actions to requery other models affected upon Saving

What is your page load time by the way?


Thanks! Good ideas. I just started looking at model actions, and implemented them with a pop-up window that creates a new record - able to use standard save/cancel in a field editor and have it close the popup and requery my table of existing records.

our opportunity object has several workflow rules, formula fields, and roll up fields, I can’t remember specficially what it was, but yes I’m sure I need to requery. 

Will change so that my title component that carries the save/cancel just uses the standard ones and then set actions on my models that need it to requery after saving. We have a few join objects that need this in order to update the opportunity properly. 

Page load time is slow I think. I’m not sure how best to time it. In Chrome’s Network tab of the console, after hitting refresh there was 5.95s of waiting time and 2.63s of content download to refresh.



Reply