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
nwesoccernwesoccer 

Invoke Validation

I have a overridden save function on a VF page.  I need to be able to make a callout, but only if the information in the custom object is valid.  I can't call the UPSERT and then do the callout, because salesforce doesn't allow that.  Is there any way to invoke the validation rules on the object to see if all the info is valid, then do the callout, then the UPSERT?

mtbclimbermtbclimber

No there's no way to run validation without calling a DML operation which will establish the restriction against performing a callout.  Your only options right now are to do the callout before the upsert or to drop the callout into an async (@future) method. 

 

That is an interesting idea though if really all you want is to exercise formula-based validation rules. If you also have validation in your triggers then we'd need to call the dml operation for sure. If you think your use case would be satisfied by just evaluating formula-based validation outside of a DML operation and you'd use it you should post an idea for it on the ideaexchange, see the "ideas" tab in the navigation above. 

 

Regards,