You can use a Schema.getGlobalDescribe() and check for the presence of the Territory object, or you could use a try-catch block on an account to programmatically check for the presence of a Territory field (using Dynamic Apex).
You can use a Schema.getGlobalDescribe() and check for the presence of the Territory object, or you could use a try-catch block on an account to programmatically check for the presence of a Territory field (using Dynamic Apex).
There's no way to easily detect any "addon" feature (multi-currency, translation workbench, territory management, etc) short of checking for the presence of an object unique to that feature. If you directly reference the object (e.g. Territory) in your code, then your package will be marked as "requiring feature X", and you won't be able to install the package on an organization that does not have that feature enabled.
You can use a Schema.getGlobalDescribe() and check for the presence of the Territory object, or you could use a try-catch block on an account to programmatically check for the presence of a Territory field (using Dynamic Apex).
All Answers
You can use a Schema.getGlobalDescribe() and check for the presence of the Territory object, or you could use a try-catch block on an account to programmatically check for the presence of a Territory field (using Dynamic Apex).
Thanks for a reply. But is there any field on Standard object (e.g. Organization) that tells whether territory enabled on org?
There's no way to easily detect any "addon" feature (multi-currency, translation workbench, territory management, etc) short of checking for the presence of an object unique to that feature. If you directly reference the object (e.g. Territory) in your code, then your package will be marked as "requiring feature X", and you won't be able to install the package on an organization that does not have that feature enabled.