While performing a routine deployment to Salesforce we encountered a really weird issue:
We double checked if we have missed any permissions or something else but no, everything was ok.
In order to keep this story short, we found our smoking gun:
If we comment that line, at least the SOQL, the issue automagically gets fixed. What???
After more research and dozens of interactions with Salesforce support we found that this is a known issue with the plattform:
Salesforce has a workaround for this, but it will require to have Salesforce helping us to deploy this line after a regular release every time.
In other words:
- We deploy all our changes
- Ask Salesforce to deploy that code
Then in a subsequent release:
- We comment that line and deploy (reference to geolocation is gone)
- Deploy any additional code - BAU
- Uncomment line on lower environment
- Ask Salesforce to deploy that code referencing geolocation
- And repeat this forever until Salesforce fixes that issue
OR
Convert that query into a String:
By doing this we tricked the Compiler, so the validation that breaks the whole deployment never is executed, therefore our code is just executed/compiled during runtime.
Voila!!!