Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link

It shouldn't change, but why hardcode?

I would put the OrgId in a custom setting, and read it from there. That way you can test in Sandboxes, work in Prod and, if it ever changes, it's 5 minutes to modify without any code "movement".

UPDATE

There are a few things you can do that do not involve hardcoding... hopefully one of them will work

  1. To log into production you hit login.salesforce.com, sandbox is test.salesforce.com. Perhaps you can identify your environment because of that.
  2. Alternatively, you can call a method in SFDC to return whether the org you're hitting is "Prod" or Sandbox". A simple SoQL query will return that: select Id, IsSandbox from Organization limit 1. See herehere for more details.

It shouldn't change, but why hardcode?

I would put the OrgId in a custom setting, and read it from there. That way you can test in Sandboxes, work in Prod and, if it ever changes, it's 5 minutes to modify without any code "movement".

UPDATE

There are a few things you can do that do not involve hardcoding... hopefully one of them will work

  1. To log into production you hit login.salesforce.com, sandbox is test.salesforce.com. Perhaps you can identify your environment because of that.
  2. Alternatively, you can call a method in SFDC to return whether the org you're hitting is "Prod" or Sandbox". A simple SoQL query will return that: select Id, IsSandbox from Organization limit 1. See here for more details.

It shouldn't change, but why hardcode?

I would put the OrgId in a custom setting, and read it from there. That way you can test in Sandboxes, work in Prod and, if it ever changes, it's 5 minutes to modify without any code "movement".

UPDATE

There are a few things you can do that do not involve hardcoding... hopefully one of them will work

  1. To log into production you hit login.salesforce.com, sandbox is test.salesforce.com. Perhaps you can identify your environment because of that.
  2. Alternatively, you can call a method in SFDC to return whether the org you're hitting is "Prod" or Sandbox". A simple SoQL query will return that: select Id, IsSandbox from Organization limit 1. See here for more details.
added 646 characters in body
Source Link
Sebastian Kessel
  • 13.2k
  • 12
  • 38
  • 61

It shouldn't change, but why hardcode?

I would put the OrgId in a custom setting, and read it from there. That way you can test in Sandboxes, work in Prod and, if it ever changes, it's 5 minutes to modify without any code "movement".

UPDATE

There are a few things you can do that do not involve hardcoding... hopefully one of them will work

  1. To log into production you hit login.salesforce.com, sandbox is test.salesforce.com. Perhaps you can identify your environment because of that.
  2. Alternatively, you can call a method in SFDC to return whether the org you're hitting is "Prod" or Sandbox". A simple SoQL query will return that: select Id, IsSandbox from Organization limit 1. See here for more details.

It shouldn't change, but why hardcode?

I would put the OrgId in a custom setting, and read it from there. That way you can test in Sandboxes, work in Prod and, if it ever changes, it's 5 minutes to modify without any code "movement".

It shouldn't change, but why hardcode?

I would put the OrgId in a custom setting, and read it from there. That way you can test in Sandboxes, work in Prod and, if it ever changes, it's 5 minutes to modify without any code "movement".

UPDATE

There are a few things you can do that do not involve hardcoding... hopefully one of them will work

  1. To log into production you hit login.salesforce.com, sandbox is test.salesforce.com. Perhaps you can identify your environment because of that.
  2. Alternatively, you can call a method in SFDC to return whether the org you're hitting is "Prod" or Sandbox". A simple SoQL query will return that: select Id, IsSandbox from Organization limit 1. See here for more details.
Source Link
Sebastian Kessel
  • 13.2k
  • 12
  • 38
  • 61

It shouldn't change, but why hardcode?

I would put the OrgId in a custom setting, and read it from there. That way you can test in Sandboxes, work in Prod and, if it ever changes, it's 5 minutes to modify without any code "movement".