• NickOlendorf
  • NEWBIE
  • -2 Points
  • Member since 2011
  • Information Technology Administrator
  • Investment Planners, Inc.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Good evening,

 

I am a novice Apex developer, and I have been having some issues getting the below code to work.  At this point, I am sure I am missing something, but I have tried so many things, I am not sure what it is!  I have created three custom objects:

 

Organizational_Goal__c, Departmental_Goal__c, and Individual_Goal__c

 

These objects are set up with a Master-Detail relationship, and what I want to do is to display the goals in a table, beginning on the left with the Org Goal, then in the middle column, I would like the Dept Goal, then lastly in the right column the Ind. Goal.  Initially, I had the Org and Dept Goals duplicated, as each one was listed for each Ind. Goal.  It ends up being too much data in the table, similar to what I found with the report.  I just want to bring back the Name and ID of each Individual Goal, and it's related Dept and Org Goals, without having them repeated in the table.  So it should look something like this:

 

Organizational Goal

Departmental Goal

Individual Goal

Org Goal #1

Dept Goal #1.1

 

Individual Goal #1.1.1

Individual Goal #1.1.2

Individual Goal #1.1.3

Dept Goal #1.2

Individual Goal #1.2.1

Individual Goal #1.2.2

Individual Goal #1.2.3

Dept Goal #1.3

Individual Goal #1.3.1

Individual Goal #1.3.2

Individual Goal #1.3.3

Org Goal #2

Dept Goal #2.1

 

Individual Goal #2.1.1

Individual Goal #2.1.2

Individual Goal #2.1.3

Dept Goal #2.2

Individual Goal #2.2.1

Individual Goal #2.2.2

Individual Goal #2.2.3

Dept Goal #2.3

Individual Goal #2.3.1

Individual Goal #2.3.2

Individual Goal #2.3.3

 

 

 The alignment on the table was altered when I tried to submit, but the goals should all be lined up under their respective headings.

 

Right now I can only seem to either get the Org and Dept to duplicate - or - I only see Org Goals.

 

Here is my controller code:

 

public class GoalList {
public ApexPages.StandardSetController setQuery1 {
        get {
            if(setQuery1 == null) {
                setQuery1 = new ApexPages.StandardSetController(Database.getQueryLocator(
                
                    [SELECT ID, Name, (SELECT ID, Name FROM Departmental_Goals__r) FROM Organizational_Goal__c 
                    ]));                                                  
            }
            return setQuery1;

        }
        set;
    }
          
    // Initialize setCon and return a list of records 
    public List<Organizational_Goal__c> getGoals() {
        return (List<Organizational_Goal__c>) setQuery1.getRecords();
    }   
}

 

 

Here is my VF page code:

 

<apex:page controller="GoalList">
    <apex:pageBlock >
    <apex:pageBlockTable value="{!Goals}" var="o">
    <apex:column value="{!o.Name}"/>
        <apex:repeat id="ColumnsRpt" value="{!o.Departmental_Goals__r}" var="col">   
               <apex:pageBlockTable value="{!col}" var="ac">
                        <apex:column value="{!ac.Name}"/>
               </apex:pageBlockTable>         
         </apex:repeat>              
    </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 

Any suggestions for a total newbie?

 

Thanks for your help!

 

Troy

 

 

Good evening,

 

I am a novice Apex developer, and I have been having some issues getting the below code to work.  At this point, I am sure I am missing something, but I have tried so many things, I am not sure what it is!  I have created three custom objects:

 

Organizational_Goal__c, Departmental_Goal__c, and Individual_Goal__c

 

These objects are set up with a Master-Detail relationship, and what I want to do is to display the goals in a table, beginning on the left with the Org Goal, then in the middle column, I would like the Dept Goal, then lastly in the right column the Ind. Goal.  Initially, I had the Org and Dept Goals duplicated, as each one was listed for each Ind. Goal.  It ends up being too much data in the table, similar to what I found with the report.  I just want to bring back the Name and ID of each Individual Goal, and it's related Dept and Org Goals, without having them repeated in the table.  So it should look something like this:

 

Organizational Goal

Departmental Goal

Individual Goal

Org Goal #1

Dept Goal #1.1

 

Individual Goal #1.1.1

Individual Goal #1.1.2

Individual Goal #1.1.3

Dept Goal #1.2

Individual Goal #1.2.1

Individual Goal #1.2.2

Individual Goal #1.2.3

Dept Goal #1.3

Individual Goal #1.3.1

Individual Goal #1.3.2

Individual Goal #1.3.3

Org Goal #2

Dept Goal #2.1

 

Individual Goal #2.1.1

Individual Goal #2.1.2

Individual Goal #2.1.3

Dept Goal #2.2

Individual Goal #2.2.1

Individual Goal #2.2.2

Individual Goal #2.2.3

Dept Goal #2.3

Individual Goal #2.3.1

Individual Goal #2.3.2

Individual Goal #2.3.3

 

 

 The alignment on the table was altered when I tried to submit, but the goals should all be lined up under their respective headings.

 

Right now I can only seem to either get the Org and Dept to duplicate - or - I only see Org Goals.

 

Here is my controller code:

 

public class GoalList {
public ApexPages.StandardSetController setQuery1 {
        get {
            if(setQuery1 == null) {
                setQuery1 = new ApexPages.StandardSetController(Database.getQueryLocator(
                
                    [SELECT ID, Name, (SELECT ID, Name FROM Departmental_Goals__r) FROM Organizational_Goal__c 
                    ]));                                                  
            }
            return setQuery1;

        }
        set;
    }
          
    // Initialize setCon and return a list of records 
    public List<Organizational_Goal__c> getGoals() {
        return (List<Organizational_Goal__c>) setQuery1.getRecords();
    }   
}

 

 

Here is my VF page code:

 

<apex:page controller="GoalList">
    <apex:pageBlock >
    <apex:pageBlockTable value="{!Goals}" var="o">
    <apex:column value="{!o.Name}"/>
        <apex:repeat id="ColumnsRpt" value="{!o.Departmental_Goals__r}" var="col">   
               <apex:pageBlockTable value="{!col}" var="ac">
                        <apex:column value="{!ac.Name}"/>
               </apex:pageBlockTable>         
         </apex:repeat>              
    </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 

Any suggestions for a total newbie?

 

Thanks for your help!

 

Troy

 

 

Hi All,

 

I want to do certification on salesforce.If any one know which material is usefu Plz guide me.

If any dumps are there plz send me those links.Plz guide me in properway.

 

Thanks in advance,

Manu

  • June 22, 2010
  • Like
  • 0