An action to create a record, wait for workflows to trigger, then delete the record

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Hello!

I'm trying to chain together a series of actions (row action on Campaign table):
  1. Create a Contact
  2. Create a Campaign Member linking Contact with Campaign
  3. Delete the Contact
In between 2 and 3 I'd like to wait a while so that a workflow is triggered and an Outbound Message gets sent.

At the moment, the workflow doesn't trigger because Skuid's just tooo g'darn' fast and, I'm guessing, deletes the record before Salesforce has worked out what day of the week it is...

So - is there any way of waiting around a little while in between 2 and 3? I've tried putting point 3 as an action on the model instead - no dice.

Cheers!

Louis
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
  • like there's an awful lot to do

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Probably not ideal, but you could run a quick javascript snippet between 2 and 3 with
setTimeout(2000) (or however many milliseconds you want to wait).
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
That's a good idea - I'll give it a go. Cheers Matt.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
I'm usually opposed to forcing the user to wait an arbitrary time interval, or trying to guess how many milliseconds to wait arbitrarily, but Matt's approach is a fairly simple one. Another approach would be to still use a setTimeout, but with a shorter interval, e.g. 500 ms, and to re-query your Model until certain conditions are met --- i.e. if there is a Boolean flag on your record that indicates that the Outbound Message processing has completed, wait until this flag is true, and then proceed with deleting the record. If you don't do this, you run the risk of deleting the record before the workflows trigger...
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Definitely better if there's some kind of field change or other indication that you can watch for. Nice idea, Zach.
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Good idea - I'll add a field update to my workflow, I can then loop through using the snippet and delete once flagged.

Cheers guys!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
We are totally adding this quote to our marketing: 
 Skuid's just tooo g'darn' fast and, I'm guessing, deletes the record before Salesforce has worked out what day of the week it is...