function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Laura SpellmanLaura Spellman 

Querying the Forecast Heirarchy

Hey there,

I am building a custom 'Customizable Forecast' tab from scratch using Visualforce and a custom controller to add some new features. One of my requirements is to forecast off of the 'forecast heirarchy' defined in the Setup->Build->Customize->Forecasts (Customizable)->Forecasts Hierarchy. Until now, I've used the UserRoleId Field to find direct reports and subordinate roles/users. How can I use SOQL to query the Forecast Heirarchy for Direct Reports and  subordinate users instead? I can not find any info on an object that contains this information.



 
Best Answer chosen by Laura Spellman
NagendraNagendra (Salesforce Developers) 
Hi Laura,

It's still based on UserRole, as far as I understand. That object has a ForecastUserId field:

The ID of the forecast manager associated with this role. The label is User ID.

You can see whether an individual User record has forecasting enabled using the ForecastEnabled field:

Indicates whether the user is enabled as a Forecast Manager (true) or not (false) in customizable forecasting. Forecast managers see forecast rollups from users below them in the forecast hierarchy.

Between these two fields, you should have all the data you would be able to pull from the Forecasts Hierarchy screen.

Hope this helps.

Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Laura,

It's still based on UserRole, as far as I understand. That object has a ForecastUserId field:

The ID of the forecast manager associated with this role. The label is User ID.

You can see whether an individual User record has forecasting enabled using the ForecastEnabled field:

Indicates whether the user is enabled as a Forecast Manager (true) or not (false) in customizable forecasting. Forecast managers see forecast rollups from users below them in the forecast hierarchy.

Between these two fields, you should have all the data you would be able to pull from the Forecasts Hierarchy screen.

Hope this helps.

Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
This was selected as the best answer
Laura SpellmanLaura Spellman
Awesome, Thanks for the very clear answer. My issue was fixed by adding an additional query on the users ForecastEnabled field likie you suggest.
Akash jena 3Akash jena 3
hi Laura please suggest me how to do the whole 'Customizable Forecast' tab from scratch using Visualforce