0

I need , when a record change, to update perform a call to my backend and I have in mind different strategies:

  1. Workflows, which will ensure that each time that object is changed, a call is performed
  2. Trigger (is it a good idea though?)
  3. Process Builder?

The obvious difference between using Workflows and custom Apex is that if I use Workflows I'll need to add API to my backend to deal with salesforce data model, while if I call the webservice from my custom Apex call I can totally prepare the right datamodel.

Also can the endpoint for the workflows be customized by using a setting?

1

There are other factors/options too. You could use batch/scheduled Apex to send groups of records. Depending on the volume of records and the number of changes, this might be more efficient.

I've successfully used the workflow method. You can choose some details about what gets sent by the workflow callout, and it requires no coding on the SF side, which can make it good. Although it is harder to debug because the SF side is pretty much a black box to you.

And I've successfully done this using Apex fired from a trigger (asynchronously - you cannot just call out from a trigger).

And I've done the scheduled sort of thing too.

I haven't used Process Builder for this - I'm not sure that I would. It does have weird pitfalls, and workflows can get the job done.

I would say that:

  • If you're not that familiar with Apex coding, but you are happy to do the work in the external system, workflows make a lot of sense.

  • If you're happy with Apex coding (and can live with the callouts happening minutes after the record change), the scheduled/batch callouts is a pretty good option.

  • It's a fairly complex Apex task to fire asynchronous callouts from a trigger with all the appropriate error handling to make it reliable. It's probably the "best" but it is definitely the most effort.

Personally, I'd go with last of those options, but that's because I wrote a framework to make it easy to manage firing callouts from triggers :)

PS, the workflow's endpoint cannot (as far as I know) come from a custom setting. But it is just a field in the workflow that you can change later, so it's not difficult to update.

  • I prefer no scheduling, realtime. So one option could be process builder + invocable method? – Edmondo1984 Mar 23 '17 at 9:55
  • 1
    I haven't tried the PB method. You would still have to make your Apex break out of being synchronous (salesforce.stackexchange.com/questions/120012/…) so it's still a little elaborate to get the error handling right. If I were you, I'd go with workflow. – Aidan Mar 23 '17 at 9:59
  • How do you handle authentication at the server side with the workflow? – Edmondo1984 Mar 24 '17 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.