How to poll Salesforce Record until future callout is completed and record has changed

I’m most likely not understanding this problem correctly, so I may be barking up the wrong tree, but I’m going to do my best to explain the problem.

Short Version
How can I poll a Salesforce record until the asynchronous method has completed? I believe I have to use a asynchronous method because I’m calling out to a web service from a trigger and I can only do that with the @future method.  

Long Version
I have a Skuid page that is using Stripe Checkout API. I’m using the server-side method by using a custom object called Transaction__c.  When the transaction record status equals ‘Process Payment’ it triggers the Apex Class to do a HTTP call to Stripe to start processing the payment. 

I have to use a “@future method” to perform the callout since salesforce won’t let me perform a callout from a trigger without making it asynchronous. How can I make the Skuid page wait and keep checking the Salesforce record until it has gone to the correct Status?

I hope this makes sense. I’m in very unfamiliar territory. 

Appreciate any help you can give!

Thank you  

Hey Sam,

There are 2 community post about the pieces you’ll want here. It’ll tell you how to:

  1. Query the data via JS -
  2. Set a time interval with JS -
I believe this is how this could look:
  1. Your Salesforce record reaches a Status of “Done”
  2. Your Skuid page contains a Transaction model, with condition of Status = “Done” and Id = url parameter (or however you’d like to pass an id). The page continually querys for data until your Transaction model has a single row
  3. Your Skuid page triggers an action based on that row being updated or created or having data, finishing the process.
Best of luck! Transactions are a tricky business. Feel free to post progress/road blocks as they come. :slight_smile:

And if I mis-represented your issue or need, feel free to clarify further.


Hi Aaron,

Thanks, I ended up using setTimeout() and polled for changes every 5 seconds until it either completed or updated to an error. 

If anyone is looking to connect Skuid to Stripe Checkout, this is useful to make sure it goes to the payment collection step.