• Wes Barnes
  • NEWBIE
  • 25 Points
  • Member since 2007

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 15
    Replies
I have been going through the Visualforce Reference Guide using it as a tutorial. I've attempted all of the ways I can think of to feed the id number of a predefined view to the selectList and other Components, but cannot get it to automatically display the filtered list that I want instead of the list of views for the user to select from. Can someone point me in the right direction?
  • March 23, 2009
  • Like
  • 0

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

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?

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

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

 

 

 

Hello --

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
All --
 
I am looking for a way that I can assign cases using a case assignment rules based on the number of cases that a support rep has open, on hold, etc, basically anything that is not closed.  I would like to assign the case to the rep with the lowest number of cases assigned to them but I cannot seem to find a count field or any way to count open cases for a user.
 
Any ideas?
Hi all --
 
I have created a workflow rule that I want to trigger an email alert to the Support Manager when a case has a status of anything but closed after a certain period of time.  I have setup a formula with the following criteria:
 
AND(CreatedDate >  CreatedDate + 2, NOT( IsClosed))
 
This formula is supposed to (might not be right) review if the case is closed and the create date is more than 2 days.
 
The eval criteria is set to "When a record is created, or when a record is edited and did not previously meet the rule criteria"
 
The alert is set to email the Support Manager using an email template when the criteria is met.
 
This is not currently working and I was wondering if anyone has any recommendations for me to get this working.

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

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

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

 

 

 

I have been going through the Visualforce Reference Guide using it as a tutorial. I've attempted all of the ways I can think of to feed the id number of a predefined view to the selectList and other Components, but cannot get it to automatically display the filtered list that I want instead of the list of views for the user to select from. Can someone point me in the right direction?
  • March 23, 2009
  • Like
  • 0
Hello --

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
Hello,
 
Professional version with API
 
We have a custom button with exec javascript that validates a series of fields based on the user´s role before they can submit the Opp for approval by their Sales Mananger. All the standard validation works great and has been easy to access and program however I cannot figure out how to access the Opportunity Contact Role object from the native options within Salesforce to validate that a Role has been chosen, the Primary has been set, etc . . .
 
Futhermore there is no way create any valildation rules on the Opportunity Contact Role field directly or indirectly. For example if I wanted to create a validation rule on the Stage field that checks to see that the "Primary" contact has been chosen from all the contacts on the Opportunity Contact Role object when the Stage has been set to "Sold" there is no way to query the checkbox value on the "Primary" field.
 
What we want to accomplish is that no Sales Order goes forward without the "roles" of all the Opportunity Contact Roles being define and without a "Primary" chosen from all the contacts.
 
Does anyone have any ideas how this can be done?
 
thanks, crmzepher
Hi all --
 
I have created a workflow rule that I want to trigger an email alert to the Support Manager when a case has a status of anything but closed after a certain period of time.  I have setup a formula with the following criteria:
 
AND(CreatedDate >  CreatedDate + 2, NOT( IsClosed))
 
This formula is supposed to (might not be right) review if the case is closed and the create date is more than 2 days.
 
The eval criteria is set to "When a record is created, or when a record is edited and did not previously meet the rule criteria"
 
The alert is set to email the Support Manager using an email template when the criteria is met.
 
This is not currently working and I was wondering if anyone has any recommendations for me to get this working.