• Laura Spellman
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
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.



 
Hey there!

I am new to visualforce and am currently recreating the customizable forecast tab to add some features needed by our exec team. My current question is in regards to recreating the top section of the page, seen belowootb customizable forecast - top section

Currently, I have added the new features to the page and I have to data stored in a list of lists of a class defined as forecastValues. I'll include the data structure code below.
public class forecastValues {
    public Decimal quantity{ get; set; }
    public Decimal revenue{ get; set; }
    }
public List<forecastValues> forecastCategValues{get; set;}
public List<List<forecastValues>> monthlyValues{get; set;}

        Public static forecastValues initializeForecastValues(){
            forecastValues fv = new forecastValues();
            fv.quantity = 0; fv.revenue = 0;
            return fv;
        }

        Public List<forecastValues> initializeforecastCategValues(){
            forecastCategValues = new forecastValues[5]; //one for each category: closed, commit, bestCAse, Pipeline, TOTALS

            for (integer i = 0; i < forecastCategValues.size(); i++){
                forecastCategValues[i] = initializeForecastValues();
            }
            return forecastCategValues;
        }


       Public List<List<forecastValues>> initializemonthlyValues(){
            monthlyValues = new List<List<ForecastValues>>();
            for (integer i = 0; i < integer.valueOf(selectedRangeLength); i++){ // one for each period in forecasting range: 1-6
                monthlyValues.add(initializeforecastCategValues());
           }
            return monthlyValues;
       }

So I have a <List<list<forecastValues>> monthlyValues where all of the data I'd like to display is located. From this point though, I would appreciate some help on how to display it in a visualforce table. I essentially have a groups of quantities and revenues that need to be associated with a month and forecast category on the page, but this information isnt explicitly noted in monthlyValues.

I would much appreciate any advice or help that you may have for me.  is there a way to manually name the rows and columns, etc??

Thank you!
 
So I have a set of three visual force pages. Each is a pageblock table showing results from custom controller that is limiting based on parameters passed from commandlinks on the previous pages. One of the limiting parameters is a datetime, however when I pass the parameter to the controller it comes out as a string. Either I am converting this somewhere (can the list<object> handle datetime fields?) or the visualforce page is converting the datetime field to a string that looks like this:

Fri Nov 30 21:55:38 GMT 2012

And I need to either cast this back into a datetime variable or figure out how to pass it as a datetime. Any help that could be provided would be really appreciated! 

 Here is my controller:
 
public with sharing class attendance_class_joins {

    // an instance variable for the standard controller
    private ApexPages.StandardController controller {get; set;}
    // the object being referenced via url
    //private Lesson__c lesson {get; set;}
    // the variable getting set from the command button 
    public String className {get; set;}
    public String classTimeStr {get; set;}
    //public DateTime ClassTime {get; set;}
    
    
    //---------------------------------------------------------------------
    //Create list for student attendance of all active classes 
    //by using SOQL (seriously salesforce?) to generate list
    
    public ApexPages.StandardSetController activeclassList {
       get {
            if(activeclassList == null) {
                activeclassList = new ApexPages.StandardSetController(
                    Database.getQueryLocator([SELECT Name, Teacher__r.name 
                                              FROM Lesson__c 
                                              WHERE Inactive_lesson__c = False]));
            }
            return activeclassList;
        }
        set;
    }
    
    // Initialize setCon and return a list of records
    public List<Lesson__c> getActiveClasses() {
        return (List<Lesson__c>) activeClassList.getRecords();
    }
    
    
    // handle the action of the commandButton
    public PageReference processLinkClickSA() {
        System.debug('className: '+className);
        return page.lessonselection;
        //Now do something
    	 //go to page http://cs16.salesforce.com/apex/lessonselection
        //return null;
    }
    //------------------------------------------------------------------
    //Create the list for the lesson selection page.
    
    public ApexPages.StandardSetController classtimeList {
       get {
            if(classtimeList == null) {
                classtimeList = new ApexPages.StandardSetController(
                    Database.getQueryLocator([SELECT Name, Date_Time__c 
                                              FROM Lesson_Attendance__c 
                                              WHERE Lesson_ID__r.Name in (:className)
                                              AND Attendance__c = Null]));
            }
            return classtimeList;
        }
        set;
    }
    
    // Initialize setCon and return a list of records
    public List<Lesson_Attendance__c> getClassTimes() {
        return (List<Lesson_Attendance__c>) classtimeList.getRecords();
    }
    
    // handle the action of the commandButton
    public PageReference processLinkClickLS() {
        System.debug('className: '+className);
        //datetime classTime = DateTime.parse(classTimeStr);
        return page.takeroll;
    	 //Now do something
    	 //go to page http://cs16.salesforce.com/apex/lessonselection
        //return null;
    }
    
    //---------------------------------------------------------
    
    //serialize the date/time function gotten on the last page. 
    //datetime classTime = DateTime.parse(classTimeStr);
    //public DateTime classTimeStr() {
    //datetime classTime = ApexPages.currentPage().getParameters().get('classTimeStr');
    //return (DateTime)Json.deserialize(classTimeStr, DateTime.class);
	//}
    //Create the list for the take roll page
 	public ApexPages.StandardSetController rollcallList {
       get {
            if(rollcallList == null) {
                rollcallList = new ApexPages.StandardSetController(
                    Database.getQueryLocator([SELECT Student_ID__r.Name, Attendance__c, Notes__c 
                                              FROM Lesson_Attendance__c
                                              WHERE Lesson_ID__r.Name in (:className)]));
                                              	//AND Date_Time__c = :classTime]));
            }
            return rollcallList;
        }
        set;
    }
    
    // Initialize Roll call and return a list of records from the above query.
    public List<Lesson_Attendance__c> RollCall {get {
        return (List<Lesson_Attendance__c>) RollCallList.getRecords();
    }}
    
    //Custom save functionality.
    public PageReference save() {
        update RollCall;
        return page.Test_Page;
    }

}
And here are my visual force pages
 
<apex:page controller="attendance_class_joins">
  <h1>Student Attendance</h1>
  <h1>Student Attendance</h1>
  <body>This is where you can take roll and check students attendance records.</body>
  <body>Please select the class series you would like to take attendance for: </body>
      
      <apex:form >
     <apex:pageBlock title="List of Active Classes">
          <apex:pageBlockSection columns="1" >
              <apex:pageBlockTable value="{!ActiveClasses}" var="c">
                  <apex:column headerValue="Lesson Name">
                      <apex:outputText value="{!c.Name}"/>
                  </apex:column>
                  <apex:column headerValue="Teacher">
                      <apex:outputText value="{!c.Teacher__r.Name}"/>
                  </apex:column>
                  <apex:column headerValue="Choose Class">
                  	<apex:commandLink value="Next" action="{!processLinkClickSA}">
                        <apex:param name="classNameParam"
                                    value="{!c.Name}"
                                    assignTo="{!className}"/>
                  </apex:commandLink>
                  </apex:column>
                </apex:pageBlockTable>
          </apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>


</apex:page>




<apex:page controller="attendance_class_joins">
  <h1>Class Selection</h1>
  <body>Select the individual meeting of {!className} that you would like to take attendance for:</body>
      <apex:Form >
    	<apex:pageBlock title="List of {!className} Sessions">
          <apex:pageBlockSection columns="1" >
              <apex:pageBlockTable value="{!ClassTimes}" var="d">
                  <apex:column headerValue="Date/Time">
                      <apex:outputText value="{0,date,yyyy-MM-dd HH:mm:ss}">
                          <apex:param value="{!d.Date_Time__c}"/>
                          </apex:outputText>
                  </apex:column>
              		<apex:column headerValue="Choose Class">
                  		<apex:commandLink value="Next" action="{!processLinkClickLS}">
                        	<apex:param name="classTimeParam"
                                        value="{!d.Date_Time__c}"
                                		assignTo="{!classTimeStr}"/>
                  		</apex:commandLink>
                  	</apex:column>  
              </apex:pageBlockTable>
          </apex:pageBlockSection>
      </apex:pageBlock>
    </apex:Form>
</apex:page>


<apex:page controller="attendance_class_joins">
    <h1>
        Take roll call, select the correct attendance value from the dropdown for each student and add notes where appropriate. Then click save to commit.
    </h1>
    <apex:form >
        <apex:pageBlock title="Roll Call" >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save"
                                    action="{!save}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!rollcall}" var="stud">
                <apex:column headerValue="Student">
                    <apex:outputText value="{!stud.Student_ID__r.Name}"/>
                </apex:column>
                <apex:column headerValue="Attended?">
                    <apex:inputField value="{!stud.Attendance__c}"/>
                </apex:column>
                <apex:column headerValue="Notes">
                    <apex:inputField value="{!stud.Notes__c}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>