1

If 2 users in SF try to insert accounts at the same time(assume it) considering we didn't bulkified our code in helper classes.

Now we know, whenever users try to use such functionalities from SF UI it'll create separate transactions for them but our Apex triggers will consider both the transactions as single(and concurrently) and will operate the logic correct?

I mean what issues this Scenario can cause and what is happening behind the scenes?

2 Answers 2

2

If 2 users in SF try to insert accounts at the same time(assume it) considering we didn't bulkified our code in helper classes.

Each user have its own transaction, thus this will run two parallel transaction.

Apex triggers will consider both the transactions as single(and concurrently) and will operate the logic correct?

No, it will be two different transaction, both running the same trigger. One unaware of the other.

3
  • 1
    Hi @Damecek, that means bulkification is not meant for this scenario. It is for when we try to load large volume of data from a single user context via dataloader or API? Commented Aug 15 at 8:16
  • Please correct me what is the role of bulkification in triggers? Commented Aug 15 at 8:16
  • Yes, mostly. The bulkification is term used in trigger context to refer to ability to work with lists of records rather than single records. Each trigger is being run in chunks of at most 200 records. This can be triggered by import, API or simple from other apex or flow, when inserting a list of records.
    – Damecek
    Commented Aug 15 at 8:27
0

The only way (on the SFDC platform) two different users' "update events" will be considered as a single SFDC transaction is if

  • User[0] publishes a platform event E
  • User[1] publishes a platform event E

where Trigger T subscribes to Platform Event E

If the two publications occur close enough in time, then it is possible, though not guaranteed, that a single SFDC transaction that executes trigger T will bulk both events (E(0) and E(1).

Of course, to the end user, the platform events execute asynchronously to the original transaction(s) that published the event(s).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .