You need to sign in to do that
Don't have an account?
Chad Kovac
Trying to simply show two sub-items (children) using Apex
Using the example here:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_dataTable.htm
I'm trying to get the following code to work:
Now, I this is only the first step. I also have Opportunity_SubGroup__c that exist under Opportunity_Group__c
Apex page:
Ideally, I'll need to list related groups and subgroups on the opportunity page.
Maybe something like these will be needed in my Class?
Instead of Tasks and Events I'd need Opportunity_Groups__c and Opportunity_Subgroups__c
Any help?
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_dataTable.htm
I'm trying to get the following code to work:
Now, I this is only the first step. I also have Opportunity_SubGroup__c that exist under Opportunity_Group__c
Apex page:
<apex:page controller="oppHierarchy" id="thePage"> <apex:dataTable value="{!OGs}" var="Opportunity" id="theTable" rowClasses="odd,even" styleClass="tableClass"> <apex:facet name="caption">table caption</apex:facet> <apex:facet name="header">table header</apex:facet> <apex:facet name="footer">table footer</apex:facet> <apex:column> <apex:facet name="header">Name</apex:facet> <apex:facet name="footer">column footer</apex:facet> <apex:outputText value="{!OGs.name}"/> </apex:column> <apex:column> <apex:facet name="header">Quantity</apex:facet> <apex:facet name="footer">column footer</apex:facet> <apex:outputText value="{!OGs.Quantity__c}"/> </apex:column> </apex:dataTable> </apex:page>Class:
public class oppHierarchy { List<Opportunity_Group__c> OGs; public List<Opportunity_Group__c> getOGs() { if(OGs == null) OGs = [select name, Quantity__c from Opportunity_Group__c limit 10]; return OGs; } }
Ideally, I'll need to list related groups and subgroups on the opportunity page.
Maybe something like these will be needed in my Class?
public List<Task> getRelatedTasks() { return [select Id, Subject, ActivityDate, Status, Owner.Name, What.Name, Account.name, Type, CallType from Task where AccountId in :AllIds Order By ActivityDate Desc]; } public List<Event> getRelatedEvents() { return [select Id, Legacy_Calltype__c, Subject, Type, Event_Status__c, Owner.Name, What.Name, ActivityDate from Event where WhatId in :AllIds Order By ActivityDate Desc]; }
Instead of Tasks and Events I'd need Opportunity_Groups__c and Opportunity_Subgroups__c
Any help?
vf page
i still think you should be thinking about overwritting the main opportunity page - that way when this is empty you're not going to be left with a blank box in the middle of the page...
let me know if you have any issues i haven't fully tested other than to create a could of opps with opp groups and subgroups..
cheers
dan
All Answers
if so what's the relationships between Opportunity, Opportunity_Groups__c & Opportunity_Subgroups__c
The Opporrtunity Group is linked to the Opportunity (Master) using "Opportunity__c"
The Opportunity Subgroup is linked to the Opportunity Group (Master) using "Opportunity_Group__c"
I think I'm on the right track but it's going to be a little more detailed than what I have.
Also, I can't just use a single Join between Opp Groups and Subgroups to return a single list because the list structures vary, right?
i would possibly overide the view page and use the standardcontroller="opportunity" then make this an extension.
i'll share an example in a bit just between locations..
We've been trying to find an Apex class close so I don't have to keep doing this painful trial and error self-teaching thing but it's been challenging.
extension:
vf page:
this is setup for overriding the default view for an opportunity..
hope it helps steer you in the right direction.
It seems to be repeating itself (the whole page) so I opened /apex/Opportunity_Hierarchy?id=006m0000002FZRP and saw the same behavior.
If I can just get a working result for this I think I'd be able to conquer the world! At least.. of beginning APEX. ;)
I had to modify the code a bit because it's actually SubGroup not Sub Group:
Class:
Page:
I'd like to include this as a VF page on the opportunity page but if I have to use it as a page all by itself, that's fine also. Just so I can see how it was done so I can get in there and tweak it.
slightly easier to see the results here... wonder why SFDC makes it so small.
if you want to embed it in a opp page then remove line 2 of the vf page.
then edit your opportunity page layout and you should see an option to add the layout - the reason included in a page override is that if there is nothing in there nothing is displayed thanks to the redended on the page:block..
If I want the Group to show only the Subgroups related to it, how could I do that? Right now it shows a list of all Groups then a list of all Subgroups but the listed subgroups actually belong to the groups.
I suspect I need to modify this bit:
have a great day - you still need to write the test class for this so you can deploy it into product
something like this should do the job:
possibly typos in there but it'll give you a rough idea of what will be needed to deploy to production - aim for 100% and you should look to try and include some system.assertequals in there to validate your test at the end..
i have 2 opportunities.
i created 3 groups on 1 opportunity and 1 on the other
i created 10 sub groups on each of the 4 groups.
on opp 1 i can see 3 groups and 30 subgroups.
on opp 2 i can see 1 group and 10 subgroups.
are you more meaning that you want it to show like this.
Group 1
Sub Groups
Group 2
Sub Groups
Group 3
Sub Groups
dan
but if you have a look at this link - it kind of gives a good example of how to do it.
http://salesforce.stackexchange.com/questions/13397/visualforce-displaying-from-nested-query
I don't see myFeedVar anywhere...
<apex:repeat value="{!myFeed}" var="myFeedVar" >
so it's using myfeed in your apex class and assigned it own var in VF.
Class:
I've been busting on this for about 8 hours now. Not sure why this is so difficult a concept for me to grasp. I have a lot of experience programming in various languages but something about this is twisting my brain!
In the image below you can see what's going on. The items I crossed out in RED do not belong in those groups. I only want to show the subgroups that are "under" the parent group in each section. Ideally, I'd like a better way to format the output as well because I could have 4-6 columns in the GROUP and 4-6 in the subgroups. I've tried closing the pageblock etc., and putting another in but when I do that it doesn't even show the subgroup anymore...
so the issue your having here is in your apex code.
if you check back on the example link you'll see it's one lookup - you need to update your first list to include a select within the subgroup.
i'm moving around today but have a go and i'll see if I can replicate and post an example a bit later..
cheers
dan
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AX1mIAG
It is a request for a part-time contract resource to assist my company.
vf page
i still think you should be thinking about overwritting the main opportunity page - that way when this is empty you're not going to be left with a blank box in the middle of the page...
let me know if you have any issues i haven't fully tested other than to create a could of opps with opp groups and subgroups..
cheers
dan
I dropped the whols Facet, etc., thing. I can't wrap my mind around all that vertical to horizontal conversion. I simplified it quite a bit and am left with:
(Class)
and page:
I'm going to mess with the column formatting to force widths so I don't have two oddly sized tables. Maybe I'll merge them into a single table. Unknown. I'm tired of messing with it! haha