function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Pass control to the save process



Wondering if the following is possible via Apex coding -


I have some functioning Apex code that fires on a button-click.  At the conclusion of that code, I'd like to pass/relinquish control to the save process, (via "update obj" or other construct).  I say relinquish, because I'd like any validation rules / workflow rules to execute normally - (outside of Apex, as if the user themselves clicked "Save").  Whether the record actually is 'Saved' or generated errors is unimportant to this procedure.


Is this possible?  Thanks for any information / assistance.




When your apex calls insert, update, or upsert the DML will execute your triggers, valdiation rules, workflows. Take a look at the link below for the order of execution.


As my code isn't triggered on save, (it's triggered via a button-click), there's no danger of recursion.


So there's no way to "push the save button" via Apex, other than via an update/insert <obj> call ?





The standard controller that you're instantiated for your VF page has a Save() method that you can call which will do the Save action on the record in the controllers context.  It returns a pageReference to your apex code.  You then either use that pageReference, or build another, and navigate "out" of your VF page to wherever you want to go.