+ Start a Discussion
boBNunnyboBNunny 

Custom Object Save - Await Asynchronous Process

I'm looking for either confirmation, or possibly alternative solutions to a requirement here.

 

Our requirement is for an edit Save on a custom object to invoke a web service to send the information to it, consume the answer, and then update the custom object only if a valid answer was received back.  If not, do not save and provide an error. 

 

Since calling webservices is Asynchronous, my solution was to create a VisualForce page (I would prefer the standard page, but...) which would await the answer and then do a PageReference to the updated object View page if successful.  If not, we would present the Error Message at the top of the page.

 

Can anyone see an alternative or issue with this solution?

Pradeep_NavatarPradeep_Navatar

If you are getting values from VF page you can use StandardController and extension and if it is from custom object edit page you can use Trigger for this.

boBNunnyboBNunny

Actually I can't.  All web services are Future methods which means Asynchronous.  I need to wait for the answer before continuing to make sure we were successful.  So, the only way I saw to do that was to create a VF page and then when Save is clicked, I can wait on the Asynch process, and then communicate back to the VF page.  If it isn't a VF page, the trigger/class can't do this because control has already been returned.