1

I want to listen to the change in permissions of salesforce records. For that, I am thinking to fire a callout from an afterUpdate method of a trigger.

Whenever a record is updated through any means, it will make a callout to an external system.

Now with actions like employee promoting/demoting role can update a huge number of record permissions which will trigger that many callouts.

Can someone correct me if my understanding is correct? If so, how many concurrent callouts happens if huge records permissions are changed?

If the callout is not completed successfully, is there any way I can query these events from salesforce through anymens?

1

First, I should say that I don't think it is possible to "listen to the change in permissions of salesforce records," other than changes in the record owner--unless you mean changes to User records?

That said, if what you want is that "whenever a record is updated through any means, it will make a callout to an external system"--that sounds like a great case for Change Data Capture. Change Data Capture fires an event whenever a record changes, and external systems can subscribe to those event streams through the CometD protocol. (Internally, triggers can also be run on change events, allowing other methods for callouts if using CometD isn't an option.) If there is a transmission failure, the system does keep several days of events stored and allows for playing back events starting at a certain event sequence number.

1

For this type of use case, I prefer to use some form of integration staging table where the trigger just writes the Id of the changed record, or maybe a JSON representation of the object that changed if that helps for the callout. Then I would have a aysnc process running on that object (e.g. batch apex that runs, queueable job that is running) to make the actual callouts. That way, you can have some error handling in place if a callout fails, and retry and/or alert someone if there is an issue, but you also have an audit trail of successes etc.

0

if you want to process the record in bulk, you can go ahead with the future method inside the trigger. Also future method has a limitation of maximum 50 future method in a single transaction and therefore If that is not the scenario you can ahead with batch apex and call it from trigger.Also for a single transaction maximum 100 callout can be possible, so adjust your batch side accordingly to avoid maximum callout governor limit.

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.