+ Start a Discussion
Surendra MuthyeSurendra Muthye 

Collaborative Forecasting

We are trying to access data from ForecastingItem using Apex. The code works fine in Execute Anonymous window of Developer Console. When we try to put it as a method in Apex class, we are unable to do so. 

We have 4 Forecast Types defined and have not changed any picklist values anywhere - it is an out-of-the-box environment. 

Code:
public List<ForecastingItem> getForecastItems(List<Id> userIdList, List<Id> periodIdList, List<Id> forecastTypeList) {

List<ForecastingItem> forecastItemList = [SELECT AmountWithoutAdjustments, AmountWithoutManagerAdjustment, 
ForecastAmount, ForecastCategoryName, ForecastingTypeId, 
ForecastQuantity, HasAdjustment, Id, IsAmount, IsQuantity, 
IsUpToDate, OwnerId, OwnerOnlyAmount, OwnerOnlyQuantity, 
ParentForecastingItemId, PeriodId, ProductFamily, 
QuantityWithoutAdjustments, 
QuantityWithoutManagerAdjustment,
Owner.Name
FROM ForecastingItem
WHERE OwnerId in :userIdList
AND PeriodId in :periodIdList
AND ForecastingTypeId in :forecastTypeList
];

return forecastItemList;


User-added image
 
GlynAGlynA
What version of the Force.com IDE for Eclipse are you using?  From your 2nd warning, it looks like the class has been created using an API version older than 26 (the minimum for ForecastingItem).  In Eclipse, you can change the version number to 26 (or 33, or whatever) by clicking on the MetaData tab at the bottom of the editor window.
Surendra Hub MuthyeSurendra Hub Muthye
Thanks for your response. It is happening with the latest version of the API. 

In fact, I tried that in the developer console after stripping the code to the bare minimum with the same result

User-added image

User-added image