I've just upgraded some subscriber orgs to a new version of our managed package. Now, we're seeing some erroneous behaviour in the subscriber org where the only explanation I can see is that sometimes, it's still running the old version of the package.
I know that they have Process Builder flows, and custom Apex that ultimately lead to running triggers in the package.
And I can see that the Apex is built against an old version of the package.
So, question 1: How does SF resolve which version of the package to use?
For example, consider the following scenario:
The subscriber has a trigger,
SubscriberTrigger1, built against v1.0 that ends up calling a managed trigger,
SubscriberTrigger1 also ends up calling another subscriber trigger
SubscriberTrigger2 which is built against v1.1 of the package.
SubscriberTrigger2 ends up calling
Does SF keep checking the current context of which version of the package to run so that when you run it, you the following sequence:
SubscriberTrigger1, ManagedTrigger1[v1.0], SubscriberTrigger2, ManagedTrigger2[v1.1]
So, this would mean that when I write v1.1, I need to account for the possibility that v1.0 could still be running as well? Fine for when I'm adding, or optimising functionality. Nightmare, if I'm changing what I write to the database e.g.
ManagedTrigger2[v1.1] expects a value to have been written to the database by
ManagedTrigger1[v1.1], but that value is missing because the subscriber has ended up making
ManagedTrigger1[v1.0] run instead.
What about asynchronous code? Do future, batch, and queueable still come from the same version as was declared in subscriber's Apex?
What about dependency injection by doing
Type.forname('MyClass').newInstance() in the package? Does this stick with the same version as the last piece of subscriber code?
Also, does this versioning also apply to Process Builder? I can't see any setting for PB that sets it against a specific package version.
Obviously, I've googled this but failed to find any documentation because the terms I'm searching for just seem to generic.