-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
7Questions
-
15Replies
Listing defined filter view via Standard List Controllers
-
- MVBob
- March 23, 2009
- Like
- 0
- Continue reading or reply
AggregateResult usage in VF page...
Hi all --
I have a VF page and corresponding controller extension that I am using to display parent and child account information. I am trying to total a rollup summary field at the child account level using an aggregateresult function. Here is the VF page detail:
<apex:pageBlockSection title="Account Detail"> <apex:outputText value="Account Name: "/><apex:outputText value="{!account.name}"/> <apex:outputText value="Account Type: "/><apex:outputText value="{!account.type}"/> <apex:outputText value="Institution Type: "/><apex:outputText value="{!account.Institution_Type__c}"/> <apex:outputText value="Total Spend: "/><apex:outputText value="{!TotalParentSpend}"/> <apex:outputText value="Account Owner: "/><apex:outputText value="{!account.owner.name}"/> <apex:outputText value="Last Update: "/><apex:outputText value="{!account.LastModifiedDate}"/> </apex:pageBlockSection>
and the Controller Code:
Public AggregateResult getTotalParentSpend (){ return [Select SUM(Total_Spend__c) from account where parentid= :System.currentPageReference().getParameters().get('id') and (type = 'Customer')]; }
The page and controller will save in the IDE but when I go to render the page I get an "Internal Server Error"
I am assuming that this is because the VF page is not rendering the data for that type of aggregate result but I cannot figure out how to get my sum value onto the page. Any help is appreciated.
Thanks,
Wes
-
- Wes Barnes
- September 13, 2010
- Like
- 0
- Continue reading or reply
Roll Up Summary at Parent Level
All --
I currently have an total spend field that is a roll up summary for all opportunities in an account that have closed. The issue is that this simply gives me the child account spend but does not give me the parent level spend or a roll up of all of those at the parent level. Does anyone have a good method to roll up all child account amounts and present it at the parent level?
-
- Wes Barnes
- August 09, 2010
- Like
- 0
- Continue reading or reply
Test Method Assistance...
All --
I am quite new to creating Apex classes and test methods so please be gentle. I have been coming through posts on the forms and trying to follow some of the cookbook examples but I have not been able to figure htis out. I have created an extension controller to get some support information that relates to an account. Here is the code for the controller extension:
public class ServicesExtension { public ServicesExtension(ApexPages.StandardController controller) { } Public Integer getCaseCount(){ return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id')]; } Public Integer getCaseCountOpen(){ return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = false]; } Public Integer getCaseCountOpenThisYear(){ return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = true and CreatedDate = THIS_YEAR]; } Public Case getLastOpenCase(){ return [Select Id, CaseNumber, Subject, CreatedDate from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = false Order By CreatedDate desc limit 1]; } }
And I have the following created for the test method:
@isTest private class ServicesExtentionTests { static testMethod void myUnitTest() { Account testAccount = new Account(); testAccount.Name = 'Echo360 Test Company'; testAccount.Classroom_Management_System__c='Blackboard'; testAccount.Name='My Test Company'; testAccount.Type='Customer'; insert testAccount; Case testCase = new Case(); testCase.Subject = 'My Test Case'; testCase.Status = 'Open'; testCase.AccountId = testAccount.Account_ID__c; insert testCase; PageReference pageRef = Page.AccountSummary; Test.setCurrentPage(pageRef); ApexPages.currentPage().getParameters().put('id', testAccount.id); ServicesExtension acctController = new ServicesExtension(new ApexPages.StandardController(testAccount)); Account updatedAccount = [select Classroom_Management_System__c, name, type FROM account where id = :testAccount.Id]; system.assertEquals('Blackboard', updatedAccount.Classroom_Management_System__c); system.assertEquals('My Test Company', updatedAccount.Name); system.assertEquals('Customer', updatedAccount.Type); ServicesExtension caseController = new ServicesExtension(new ApexPages.StandardController(testCase)); integer caseCount = caseController.getCaseCount(); Case updatedCase = [Select Subject, Status, AccountID from Case.ID where AccountId = :testCase.Id]; system.assertEquals('My Test Case', updatedCase.Subject); system.assertEquals('Open', updatedCase.Status); } }
The code coverage is only 27% and I think that this is because I am not covering the 3 count queries I have in the controller and the last open case query. I am not sure how I would test this for these types of queries.
Again if this is something that is APEX 101 for many of you I am sorry.
Thanks,
Wes
-
- Wes Barnes
- July 11, 2010
- Like
- 0
- Continue reading or reply
Update Custom Object with Opportunity and Account IDs within Controller...
All --
This is my first time using VF and creating a controller (shocker) and I have hit a roadblock with a project I am working on. I have a page that is executed from the opportunity that pulls the current opportuninty and account ID to display some pertinent information from the account and opportunity as well as providing a list of available product inventory. I have built the page and controller by reviewing the docs and a ton of forum post regarding wrapper classes and the use of checkboxes in a VF form page. I have most of the controller built but I do not understand how to pull it all together and insert the account and opp IDs into my customer inventory object. The goal is to loop through the list of invetory items that are selected and have the current Account and Opp IDs updated in the Inventory object. Here is the controller:
public class InventoryController { Account account; Opportunity opportunity; Inventory__c inventory; public Account getAccount() { return [select id, name, fice_code__c, resellers_name__c, type from Account where id = :ApexPages.currentPage().getParameters().get('accid')]; } public Opportunity getOpportunity() { return [select id, name, amount, type, closedate from Opportunity where id = :ApexPages.currentPage().getParameters().get('oppid')]; } public List<cInventory> inventoryList {Get; Set;} public List<cInventory> getInventory(){ if (inventoryList == null){ inventoryList = new List<cInventory>(); for(Inventory__c c : [select Id, name, inventory_type__c, status__c, MAC_Address__c, Hard_Drive_Serial__c, FPIO_serial__c, ExIO_Card_Serial_optional__c, Appliance_Ateme_Serial__c, Build_date__c, account__r.id, account__r.name from Inventory__c where status__c = 'available' and (inventory_type__c = 'sales' or inventory_type__c = 'trial') ORDER BY Build_date__c ASC limit 1000]){ inventoryList.add(new cInventory(c)); } } return inventoryList; } public PageReference processSelected(){ List<Inventory__c> selectedInventory = new List<Inventory__c>(); for(cInventory cCon : getInventory()){ if(cCon.selected == true){ selectedInventory.add(cCon.con); } } PageReference oppPage = new PageReference ('/' + ApexPages.currentPage().getParameters().get('oppid')); oppPage.setRedirect(true); return oppPage; } public class cInventory{ public Inventory__c con {get; set;} public Boolean selected {get; set;} public cInventory(Inventory__c c){ con = c; selected = false; } } }
and the VF page:
<apex:page Controller="InventoryController" tabStyle="Inventory__c"> <apex:form id="theForm"> <apex:pageBlock title="Account Information"> <apex:pageBlockSection Title="Account Section"> <apex:pageBlockTable value="{!account}" var="account"> <apex:column value="{!account.id}"/> <apex:column value="{!account.Name}"/> <apex:column value="{!account.FICE_Code__c}"/> <apex:column value="{!account.Resellers_Name__c}"/> <apex:column value="{!account.type}"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockSection title="Opportunity Section"> <apex:pageBlockTable value="{!opportunity}" var="opp"> <apex:column value="{!opp.id}"/> <apex:column value="{!opp.Name}"/> <apex:column value="{!opp.type}"/> <apex:column value="{!opp.amount}"/> <apex:column value="{!opp.closedate}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Inventory Information"> <apex:pageBlockButtons > <apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Select Inventory"> <apex:dataTable value="{!inventory}" var="c" styleClass="list"> <apex:column > <apex:facet name="header">Select</apex:facet> <apex:inputCheckbox value="{!c.selected}" /> </apex:column> <apex:column > <apex:facet name="header">MAC Address</apex:facet> <apex:outputText value="{!c.con.MAC_Address__c}" /> </apex:column> <apex:column > <apex:facet name="header">Appliance Serial Number</apex:facet> <apex:outputText value="{!c.con.name}" /> </apex:column> <apex:column > <apex:facet name="header">Inventory Type</apex:facet> <apex:outputText value="{!c.con.Inventory_Type__c}" /> </apex:column> <apex:column > <apex:facet name="header">Inventory Status</apex:facet> <apex:outputText value="{!c.con.Status__c}" /> </apex:column> <apex:column > <apex:facet name="header">Build Date</apex:facet> <apex:outputText value="{!Month(c.con.Build_Date__c)}/{!Day(c.con.Build_Date__c)}/{!YEAR(c.con.Build_Date__c)}" /> </apex:column> <apex:column > <apex:facet name="header">Account Name</apex:facet> <apex:outputText value="{!c.con.account__r.name}" /> </apex:column> </apex:dataTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
I am looking for a way to execute the update on the Inventory__c custom object and appreciate any sample code or references that folks can provide to help with this.
Thanks in advance and again sorry for being a noob.
Wes
-
- Wes Barnes
- April 20, 2009
- Like
- 0
- Continue reading or reply
Existing Case in Web to Case Form
We have been using the Web-To-Case form on our website for some time and are now looking at using it for our phone call overflow service offering and having an answering srevices using this tool. Our hope is that the overflow service and follow the same script that we do internally to take customer information on existng and new cases. Unfortunately, I have not found a way to link new data submitted in the form to an existing case in SFDC. Does anyone know if it is possible to add data to an existing case using the web-to-case form?
Thanks,
Wes Barnes
-
- Wes Barnes
- December 01, 2008
- Like
- 0
- Continue reading or reply
Case Assignment based on Opened Cases...
-
- Wes Barnes
- August 18, 2007
- Like
- 0
- Continue reading or reply
Stale Case Notification Workflow Rule...
-
- Wes Barnes
- August 15, 2007
- Like
- 0
- Continue reading or reply
AggregateResult usage in VF page...
Hi all --
I have a VF page and corresponding controller extension that I am using to display parent and child account information. I am trying to total a rollup summary field at the child account level using an aggregateresult function. Here is the VF page detail:
<apex:pageBlockSection title="Account Detail"> <apex:outputText value="Account Name: "/><apex:outputText value="{!account.name}"/> <apex:outputText value="Account Type: "/><apex:outputText value="{!account.type}"/> <apex:outputText value="Institution Type: "/><apex:outputText value="{!account.Institution_Type__c}"/> <apex:outputText value="Total Spend: "/><apex:outputText value="{!TotalParentSpend}"/> <apex:outputText value="Account Owner: "/><apex:outputText value="{!account.owner.name}"/> <apex:outputText value="Last Update: "/><apex:outputText value="{!account.LastModifiedDate}"/> </apex:pageBlockSection>
and the Controller Code:
Public AggregateResult getTotalParentSpend (){ return [Select SUM(Total_Spend__c) from account where parentid= :System.currentPageReference().getParameters().get('id') and (type = 'Customer')]; }
The page and controller will save in the IDE but when I go to render the page I get an "Internal Server Error"
I am assuming that this is because the VF page is not rendering the data for that type of aggregate result but I cannot figure out how to get my sum value onto the page. Any help is appreciated.
Thanks,
Wes
- Wes Barnes
- September 13, 2010
- Like
- 0
- Continue reading or reply
Test Method Assistance...
All --
I am quite new to creating Apex classes and test methods so please be gentle. I have been coming through posts on the forms and trying to follow some of the cookbook examples but I have not been able to figure htis out. I have created an extension controller to get some support information that relates to an account. Here is the code for the controller extension:
public class ServicesExtension { public ServicesExtension(ApexPages.StandardController controller) { } Public Integer getCaseCount(){ return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id')]; } Public Integer getCaseCountOpen(){ return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = false]; } Public Integer getCaseCountOpenThisYear(){ return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = true and CreatedDate = THIS_YEAR]; } Public Case getLastOpenCase(){ return [Select Id, CaseNumber, Subject, CreatedDate from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = false Order By CreatedDate desc limit 1]; } }
And I have the following created for the test method:
@isTest private class ServicesExtentionTests { static testMethod void myUnitTest() { Account testAccount = new Account(); testAccount.Name = 'Echo360 Test Company'; testAccount.Classroom_Management_System__c='Blackboard'; testAccount.Name='My Test Company'; testAccount.Type='Customer'; insert testAccount; Case testCase = new Case(); testCase.Subject = 'My Test Case'; testCase.Status = 'Open'; testCase.AccountId = testAccount.Account_ID__c; insert testCase; PageReference pageRef = Page.AccountSummary; Test.setCurrentPage(pageRef); ApexPages.currentPage().getParameters().put('id', testAccount.id); ServicesExtension acctController = new ServicesExtension(new ApexPages.StandardController(testAccount)); Account updatedAccount = [select Classroom_Management_System__c, name, type FROM account where id = :testAccount.Id]; system.assertEquals('Blackboard', updatedAccount.Classroom_Management_System__c); system.assertEquals('My Test Company', updatedAccount.Name); system.assertEquals('Customer', updatedAccount.Type); ServicesExtension caseController = new ServicesExtension(new ApexPages.StandardController(testCase)); integer caseCount = caseController.getCaseCount(); Case updatedCase = [Select Subject, Status, AccountID from Case.ID where AccountId = :testCase.Id]; system.assertEquals('My Test Case', updatedCase.Subject); system.assertEquals('Open', updatedCase.Status); } }
The code coverage is only 27% and I think that this is because I am not covering the 3 count queries I have in the controller and the last open case query. I am not sure how I would test this for these types of queries.
Again if this is something that is APEX 101 for many of you I am sorry.
Thanks,
Wes
- Wes Barnes
- July 11, 2010
- Like
- 0
- Continue reading or reply
Update Custom Object with Opportunity and Account IDs within Controller...
All --
This is my first time using VF and creating a controller (shocker) and I have hit a roadblock with a project I am working on. I have a page that is executed from the opportunity that pulls the current opportuninty and account ID to display some pertinent information from the account and opportunity as well as providing a list of available product inventory. I have built the page and controller by reviewing the docs and a ton of forum post regarding wrapper classes and the use of checkboxes in a VF form page. I have most of the controller built but I do not understand how to pull it all together and insert the account and opp IDs into my customer inventory object. The goal is to loop through the list of invetory items that are selected and have the current Account and Opp IDs updated in the Inventory object. Here is the controller:
public class InventoryController { Account account; Opportunity opportunity; Inventory__c inventory; public Account getAccount() { return [select id, name, fice_code__c, resellers_name__c, type from Account where id = :ApexPages.currentPage().getParameters().get('accid')]; } public Opportunity getOpportunity() { return [select id, name, amount, type, closedate from Opportunity where id = :ApexPages.currentPage().getParameters().get('oppid')]; } public List<cInventory> inventoryList {Get; Set;} public List<cInventory> getInventory(){ if (inventoryList == null){ inventoryList = new List<cInventory>(); for(Inventory__c c : [select Id, name, inventory_type__c, status__c, MAC_Address__c, Hard_Drive_Serial__c, FPIO_serial__c, ExIO_Card_Serial_optional__c, Appliance_Ateme_Serial__c, Build_date__c, account__r.id, account__r.name from Inventory__c where status__c = 'available' and (inventory_type__c = 'sales' or inventory_type__c = 'trial') ORDER BY Build_date__c ASC limit 1000]){ inventoryList.add(new cInventory(c)); } } return inventoryList; } public PageReference processSelected(){ List<Inventory__c> selectedInventory = new List<Inventory__c>(); for(cInventory cCon : getInventory()){ if(cCon.selected == true){ selectedInventory.add(cCon.con); } } PageReference oppPage = new PageReference ('/' + ApexPages.currentPage().getParameters().get('oppid')); oppPage.setRedirect(true); return oppPage; } public class cInventory{ public Inventory__c con {get; set;} public Boolean selected {get; set;} public cInventory(Inventory__c c){ con = c; selected = false; } } }
and the VF page:
<apex:page Controller="InventoryController" tabStyle="Inventory__c"> <apex:form id="theForm"> <apex:pageBlock title="Account Information"> <apex:pageBlockSection Title="Account Section"> <apex:pageBlockTable value="{!account}" var="account"> <apex:column value="{!account.id}"/> <apex:column value="{!account.Name}"/> <apex:column value="{!account.FICE_Code__c}"/> <apex:column value="{!account.Resellers_Name__c}"/> <apex:column value="{!account.type}"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockSection title="Opportunity Section"> <apex:pageBlockTable value="{!opportunity}" var="opp"> <apex:column value="{!opp.id}"/> <apex:column value="{!opp.Name}"/> <apex:column value="{!opp.type}"/> <apex:column value="{!opp.amount}"/> <apex:column value="{!opp.closedate}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Inventory Information"> <apex:pageBlockButtons > <apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Select Inventory"> <apex:dataTable value="{!inventory}" var="c" styleClass="list"> <apex:column > <apex:facet name="header">Select</apex:facet> <apex:inputCheckbox value="{!c.selected}" /> </apex:column> <apex:column > <apex:facet name="header">MAC Address</apex:facet> <apex:outputText value="{!c.con.MAC_Address__c}" /> </apex:column> <apex:column > <apex:facet name="header">Appliance Serial Number</apex:facet> <apex:outputText value="{!c.con.name}" /> </apex:column> <apex:column > <apex:facet name="header">Inventory Type</apex:facet> <apex:outputText value="{!c.con.Inventory_Type__c}" /> </apex:column> <apex:column > <apex:facet name="header">Inventory Status</apex:facet> <apex:outputText value="{!c.con.Status__c}" /> </apex:column> <apex:column > <apex:facet name="header">Build Date</apex:facet> <apex:outputText value="{!Month(c.con.Build_Date__c)}/{!Day(c.con.Build_Date__c)}/{!YEAR(c.con.Build_Date__c)}" /> </apex:column> <apex:column > <apex:facet name="header">Account Name</apex:facet> <apex:outputText value="{!c.con.account__r.name}" /> </apex:column> </apex:dataTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
I am looking for a way to execute the update on the Inventory__c custom object and appreciate any sample code or references that folks can provide to help with this.
Thanks in advance and again sorry for being a noob.
Wes
- Wes Barnes
- April 20, 2009
- Like
- 0
- Continue reading or reply
Listing defined filter view via Standard List Controllers
- MVBob
- March 23, 2009
- Like
- 0
- Continue reading or reply
Existing Case in Web to Case Form
We have been using the Web-To-Case form on our website for some time and are now looking at using it for our phone call overflow service offering and having an answering srevices using this tool. Our hope is that the overflow service and follow the same script that we do internally to take customer information on existng and new cases. Unfortunately, I have not found a way to link new data submitted in the form to an existing case in SFDC. Does anyone know if it is possible to add data to an existing case using the web-to-case form?
Thanks,
Wes Barnes
- Wes Barnes
- December 01, 2008
- Like
- 0
- Continue reading or reply
Validating Opp Contact Role fields from Custom Button on Opps Tab
- Crmzepher
- May 01, 2008
- Like
- 0
- Continue reading or reply
Stale Case Notification Workflow Rule...
- Wes Barnes
- August 15, 2007
- Like
- 0
- Continue reading or reply