Skip to main content

I would like to be able to call some JS method to cause a Field Editor in a popup to be validated, without actually saving it.  This is so that a snippet that I’m running, from a multi-step action on a popup button, can verify that the page is valid before it goes and update a series of other fields on the model prior to the save.  

Is there such a method or technique to cause validation to run on-demand, including updating the page to show the validation error and letting my JS know that the validation failed?

Thanks,

- Chris

How about using one save action for all the models with the roll back option of there are any errors? That way you can use SF validation.


Hi Pat … thanks for the recommendation, but I don’t think that will work for me.  What’s happening is there is a field editor where the user updates some values.  Based on what the user does on that form, I then (in javascript) update a few more fields (in this exact case, I’m calculating a next-best-time to call the lead and overwriting that value in the object).  When the model save fails (due to validation) the form stays up and the user fixes their errors.  However, the fields that I already set remain even though they may not be invalid based on the changes the user makes after the validation error.  So in this case, if the user changes their mind about wanting to change the next time to call the lead, my change won’t be backed out and they get in trouble.

If I back out the model, then all the other changes the user was making on that field editor would also be lost. 

I was hoping I could validate the page prior to running my script.  In truth, what I really want is a “before save” event that hooks after validation and before model save.  But since that doesn’t exist yet, I’m trying to find a decent work around!

- Chris


Clone the record being edited and attempt to save the cloned version. If everything works, update the current row. Otherwise you’ll have the current row still in edit mode.


Thanks Pat - I had considered that, but my model has a ton of on save actions that I don't want executed.  I could create yet-another-model and then use it, and then have the primary model refresh, update the fields and save it.  But that seems like a lot of overhead (both in database operations and in supporting the code effort) - so was hoping for something much easier...  Maybe no such luck?