Linked Questions

124 votes
3 answers
122k views

How can I efficiently generate a Set<Id> from a List<SObject> structure?

I have a bit of code where I've written a SOQL query that returns a list of SObject records, however I need a Set<Id> structure to pass to another method that I don't have control of (and thus ...
ca_peterson's user avatar
  • 22.9k
15 votes
2 answers
14k views

NO_MASS_MAIL_PERMISSION Error from Unit Test on SingleMailMessage

I am currently working in a Config-Only sandbox. I have a unit test that is continually failing with the following error message: System.EmailException: SendEmail failed. First exception on row 0; ...
Jesse Altman's user avatar
  • 19.7k
5 votes
7 answers
6k views

Differentiate Production/Sandbox Instance?

I know it is fairly straightforward in Apex to determine if the Salesforce instance is production org or a Sandbox org, but I wonder if the same is possible via formula? I have also read What are ...
Adrian Larson's user avatar
  • 149k
12 votes
4 answers
4k views

Converting the Salesforce Pod Id to ServerUrl/Name

Given a Salesforce Org Id, how can I determine the name and serverUrl to use with APIs?* For example, given the Org Id 00DE00001234ooT I can get the Pod/Server identifier from the first character ...
Daniel Ballinger's user avatar
10 votes
1 answer
4k views

General way to distinguish different Org types?

I need to distinguish different Org type as follows Production Org Sandbox Org Developer Org Demo Org (created by Salesforce, sometimes called SDO - or created by partners, sometimes called PDO) ...
Uwe Heim's user avatar
  • 28.3k
2 votes
3 answers
3k views

Returning PageReferences from Init - Not working in sandbox

So either I'm going nuts, or I'm overlooking something obvious, or I'm just encountering some very weird behaviour. The Setup I have a page which calls an Init action in the controller from the page ...
Matt Lacey's user avatar
  • 25.4k
7 votes
2 answers
1k views

How do you prevent outbound messages from sandbox orgs as a 3rd party developer?

I have an app that sends outbound messages via workflow rules. When a customer makes a copy of their org as a sandbox I start getting outbound messages for that org as well. Is there a best practice ...
Ryan Elkins's user avatar
  • 7,637
4 votes
2 answers
1k views

Can production org ids ever change and if so, under what circumstances?

The inspiration for this question comes from an apparent requirement to hard-code a production org id. Is it safe to rely on the production org id always remaining the same? Reason for hard-coding is ...
Bradley Thomas's user avatar
1 vote
1 answer
586 views

How to execute a class in Sandbox enviroment only, but have it on production as well?

I have created a couple of classes and a flow, that fill my sandbox with random data. I want to have these classes available to all future sandboxes that I create, but I don't want to enable that ...
Saariko's user avatar
  • 5,581
2 votes
1 answer
564 views

How do I identify whether a batch process was run from Production or testing?

I am setting up a result process based on batches and just wondered if there is a way to identify if the batch is run from the Production or Testing environment.
J_D_'s user avatar
  • 21