Posts

Showing posts with the label Issandbox

Salesforce Fact #908 | Check if current org is sandbox in LWC

Image
How to check if the current org is sandbox in LWC? One option is to call an apex method and get the data. Another option is we can use a custom field and LWC to get the data. In this approach, we create one formula field on the User object to store the current org id and then using this one, we get the IsSandbox value using getRecord on Organization object. Attached are the screenshots.

Salesforce Fact #580 | Check issandbox in validation rule and formula

Image
There is a field IsSandbox on Organization object which denotes whether the current org is a sandbox or not. But this field is not accessible using the $Organization global variable in formula field and validation rules. So, in order to check issandbox, we can create a custom metadata with a checkbox field and set it to true for sandboxes and keep it unchecked for non-sandbox orgs. Then we can refer this record in formula field and validation rules. Attached are the screenshots.