You need to sign in to do that
Don't have an account?
Mat Schaffer
Writing Classes for multiple orgs with/without RevenueForecast
So I'm working on a component which uses quotas (via RevenueForecast object), but I'd like the app to be able to operate without quotas.
I have a method in my controller like this:
public RevenueForecasts[] getRevenueForecasts() { ... }
But if I try to deploy the app into an org that doesn't have customizable forecasting enabled I get a compile error because the org doesn't know about RevenueForecast.
Is there some way to code to a generic type (maybe sObject?) so that I can just return a null quota if the org doesn't have RevenueForecast objects available?
Thanks,
Mat
All Answers
Yes, you can use describes to determine if the sobject type RevenueForecast is available, and dynamic apex to do the query:
Worked like a charm! Thanks!