• Stacey McDonald
  • NEWBIE
  • 30 Points
  • Member since 2012

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

We have a formula field that calculates the number of hours since a record was created vs. now

((NOW() - CreatedDate)*24)

I would like to modify this to only include business hours, Monday through Friday 8-5 Eastern and to no include weekends.
Any suggestions or direction would be appreciated.

Thanks,
Stacey

I have a button on one of our custom objects called Samples.  Clicking that button opens up a new window and fills in some of the fields automatically on a new opportunity.  I would like to be able to automatically link the sample record I started from to the opportunity record I am creating.  Is this possible?
I have a dashboard that has a list of accounts.  I would like to move accounts to the top of the list and color them red if a check box is checked on their account details.  Is this possible?
I borrowed some apex code to develop a editable related contact on an account visual force page.  I need to limit the related contact list to those not marked as inactive.  What code would need to be added to achieve this result?
 
/*
 * EditableContactListExtension.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   This is the implementation class where Object specific references
 *   need to be defined. Please see EditableList.cls for more information
 *   on what each method is responsible for.
 *
 *   Required methods:
 *     - EditableContactListExtension(ApexPages.StandardController)
 *     - getChildren()
 *     - initChildRecord()
 *
 */
public with sharing class EditableContactListExtension extends EditableList
{
  // Read the explanation in EditableContactListExtension(ApexPages.StandardController)
  // to see when to uncomment the following line.

  // public Account myAccount {get; private set;}

public ApexPages.StandardController controller {get;set;}

  public EditableContactListExtension(ApexPages.StandardController stdController) 
  {
    super(stdController);
    controller = stdController;

    // If necessary, explicitly query for additional metadata on parent record
    // if you are looking to display things that don't come back with the
    // StandardController. In that case, you will need to replace the "Account.X"
    // references in the Visualforce Page with references to an Account variable
    // that you will need to declare in this class (myAccount.X). I have commented out
    // an example.

    // this.myAccount = [SELECT Id,
    //                            Name,
    //                            Custom_Relationship__r.Name
    //                        FROM Account
    //                        WHERE Id =: stdController.getRecord().Id];
    
    this.childList = [SELECT Id,
                          FirstName,
                          LastName,
                          Studio__c,
                          Type__c,
                          Preferred_Contact_Frequency__c,
                          Date_Last_Contacted__c,
                          Days_Since_Contact__c
                      FROM Contact
                      WHERE AccountId =: mysObject.Id
                      ORDER BY Contact.FirstName ASC];
  }

  /*
   * This method is necessary for reference on the Visualforce page, 
   * in order to reference non-standard fields.
   */
  public List<Contact> getChildren()
  {
    return (List<Contact>)childList;
  }

  public override sObject initChildRecord()
  {
    Contact child = new Contact();
    // Can either use mysObject or acct here
    child.AccountId = mysObject.Id;
    
    return child;
  }

  public PageReference saveAll()
  {
    super.save();
    return controller.save();
  }
}
Thanks in advance!
 
I borrowed some code from the internet and now I cannot deploy it due to a code coverage error.  Is there any way around this or to fix it?
I am new to developing and I am having an issue with one of my test classes.  Can someone look it over and tell me what is wrong with it.  Here is the error I get when trying to deploy.

EditableList_Test.test_save_failure(), Details: System.AssertException: Assertion Failed: Expected: 1, Actual: 2 Class.EditableList_Test.test_save_failure: line 193, column 1

Here is the code for EditableList_Test
 
/*
 * EditableList_Test.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   Test class for EditableList.cls
 *
 */
@isTest
private class EditableList_Test 
{   
  /*
   * Mock implementation of abstract class used for testing
   */
    private class MockEditableList extends EditableList
  {
    public MockEditableList(ApexPages.StandardController stdController)
    {
      super(stdController);
    } 
  }

  private static Account acct;
  private static Contact myContact1;
  private static Contact myContact2;

  private static void setupData()
  {
    acct = new Account();
    acct.Name = 'Test Account 1';
    insert acct;

    myContact1 = new Contact();
    myContact1.LastName = 'Smith';
    myContact1.AccountId = acct.Id;
    insert myContact1;

    myContact2 = new Contact();
    myContact2.LastName = 'Smith';
    myContact2.AccountId = acct.Id;
    insert myContact2;
  }
    
    @isTest static void test_EditableList() 
  {
        setupData();

    Test.startTest();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    Test.stopTest();

    System.assertEquals(0, mock.ZERO);
    System.assertEquals(0, mock.childList.size());
    System.assertEquals(0, mock.removeChildList.size());
    }
    
  @isTest static void test_getHasChildren()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    Test.startTest();

    System.assertEquals(false, mock.getHasChildren());

    mock.childList.add(new Contact());

    System.assertEquals(true, mock.getHasChildren());

    Test.stopTest();
  }

  @isTest static void test_initChildRecord()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    Test.startTest();

    System.assert(mock.initChildRecord() instanceof Contact);
    
    Test.stopTest();
  }

  @isTest static void test_addToList()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    System.assertEquals(0, mock.childList.size());

    Test.startTest();

    mock.addToList();

    Test.stopTest();

    System.assertEquals(1, mock.childList.size());
  }

  @isTest static void test_removeFromList()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    mock.childList.add(myContact1);
    mock.childList.add(myContact2);

    Test.startTest();

    mock.removeIndex = '1';
    mock.removeFromList();

    Test.stopTest();

    System.assertEquals(1, mock.childList.size());
    System.assertEquals(myContact2.Id, mock.childList[0].Id);
    System.assertEquals(1, mock.removeChildList.size());
    System.assertEquals(myContact1.Id, mock.removeChildList[0].Id);
  }

  @isTest static void test_getSuccessURL_param()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    String retURL = '/test';
    PageReference pr = new PageReference('/');
    pr.getParameters().put('retURL', retURL);

    Test.setCurrentPageReference(pr);
    Test.startTest();

    System.assertEquals(retURL, mock.getSuccessURL().getUrl());

    Test.stopTest();
  }

  @isTest static void test_getSuccessURL_noParam()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    PageReference pr = new PageReference('/');

    Test.setCurrentPageReference(pr);
    Test.startTest();

    System.assertEquals(std.view().getUrl(), mock.getSuccessURL().getUrl());

    Test.stopTest();
  }

  @isTest static void test_save_failure()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    mock.childList.add(myContact1);
    mock.removeChildList.add(myContact2);

    // Purposely leave out required LastName
    Contact newContact = new Contact();
    newContact.AccountId = acct.Id;

    mock.childList.add(newContact);

    Test.startTest();

    System.assertEquals(null, mock.save());

    Test.stopTest();

    System.assertEquals(1, ApexPages.getMessages().size());
    System.assertEquals(ApexPages.Severity.ERROR, ApexPages.getMessages()[0].getSeverity());
    
  }

  @isTest static void test_save_success()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    mock.childList.add(myContact1);
    mock.removeChildList.add(myContact2);

    Contact newContact = new Contact();
    newContact.LastName = 'Test';
    newContact.AccountId = acct.Id;

    mock.childList.add(newContact);

    Test.startTest();

    System.assertEquals(mock.getSuccessURL().getUrl(), mock.save().getUrl());

    Test.stopTest();

    List<sObject> results = [SELECT Id FROM Contact WHERE AccountId =: acct.Id ORDER BY CreatedDate];
    System.assertEquals(2, results.size());
    System.assertEquals(myContact1.Id, results[0].Id);
    System.assertNotEquals(myContact2.Id, results[1].Id);
  }
}

 
I created a visual force page with Account Details at the top and a contact related list at the bottom.  I have Save and Cancel buttons on the page.  The Save button works after I modify a contact but does not save the modification when I change one of the account fields.  Here is my code.

---VF Page---
<apex:page standardController="Account" showHeader="true" sidebar="true" extensions="EditableContactListExtension">
    <apex:form >  
      <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Account Penetration" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                <apex:commandButton value="Print Profile" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()"/>
                <Script Language="JavaScript">function openConga() { window.open('{!URLFOR($Action.Account.Penetration_Profile,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); }  
                </Script>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Contact Penetration" columns="3">
                <apex:outputField value="{!account.Architect_Contacts__c}"/>
                <apex:outputField value="{!account.Design_Contacts__c}"/>
                <apex:outputField value="{!account.Total_Contacts__c}"/>
                <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Architect_Penetration__c}"/>
                <apex:outputField value="{!account.Design_Penetration__c}"/>
                <apex:outputField value="{!account.Total_Penetration__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Share of Wallet" columns="2">
                <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Win Rate" columns="1">
                <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                <apex:inputField value="{!account.Specifications_Won__c}"/>
                <apex:inputField value="{!account.Specifications_Lost__c}"/>
                <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection id="childList" columns="1" title="Known Contacts" collapsible="false">
        	  <!-- There is a trick to creating a counter when rendering rows in a
              pageBlockTable. You have to define a variable to default to 0,
              and then update that variable inside the table row. This is the
              way that I can leverage smart row deletes -->
        <apex:variable var="rowNum" value="{!ZERO}" />
        <apex:outputLabel value="No Contacts currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/>
        <apex:pageBlockTable value="{!children}" var="contact" rendered="{!hasChildren}" >
          <apex:column headerValue="First Name">
            <apex:inputField value="{!contact.FirstName}" />
          </apex:column>
          <apex:column headerValue="Last Name">
            <apex:inputField value="{!contact.LastName}" />
          </apex:column>
            <!-- Add additional children metadata columns here -->
          <apex:column headerValue="Studio">
            <apex:inputField value="{!contact.Studio__c}" />
          </apex:column>
          <apex:column headerValue="Type">
            <apex:inputField value="{!contact.Type__c}" />
          </apex:column>
          <apex:column headerValue="Preferred Contact Frequency">
            <apex:inputField value="{!contact.Preferred_Contact_Frequency__c}" />
          </apex:column>
          <apex:column headerValue="Date Last Contacted">
            <apex:inputField value="{!contact.Date_Last_Contacted__c}" />
          </apex:column>
          <apex:column headerValue="Days Since Contact">
            <apex:inputField value="{!contact.Days_Since_Contact__c}" />
          </apex:column>  
            <!-- This is the second half of the trick to keep track
                  of your row index for deletion. -->
            <apex:variable var="rowNum" value="{!rowNum + 1}" />
            <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList, messages" immediate="true">
              <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" />
            </apex:commandLink>
        </apex:pageBlockTable>
        <!-- Want to specify immediate here and above so validation does
              not occur when you are trying to add/remove rows. Only want
              validation to occur when trying to save -->
        <apex:commandButton value="Add Contact" action="{!addToList}" rerender="childList, messages" immediate="true" />
      	</apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>
Thanks!
Using some examples I have come up with the following Visualforce page on our accounts.  I have a few issue with it that I need some help on.
  1. The page is cut off at the bottom when added to the Account Details page.
  2. Clicking the Save button in the page does save the inputField changes but it tries to display the entire Salesforce.com window in the Apex page.
  3. Is there a way to only display this based on a checkbox being checked?
<apex:page standardController="Account" showHeader="true">
    <!-- Define Tab panel .css styles -->
    <style>
    .activeTab {background-color: #236FBD; color:white; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
            
    <!-- Create Tab panel -->
    <apex:tabPanel switchType="client" selectedTab="name1" id="AccountTabPanel"
        tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Contact Penetration" name="name1" id="tabOne">
               <apex:pageBlock >
                  <apex:pageBlockSection columns="3">
                    <apex:outputField value="{!account.Architect_Contacts__c}"/>
                    <apex:outputField value="{!account.Design_Contacts__c}"/>
                    <apex:outputField value="{!account.Total_Contacts__c}"/>
                    <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Architect_Penetration__c}"/>
                    <apex:outputField value="{!account.Design_Penetration__c}"/>
                    <apex:outputField value="{!account.Total_Penetration__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
        </apex:tab>
        <apex:tab label="Specification Share of Wallet" name="name2" id="tabTwo">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="2">
                    <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                    <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
        <apex:tab label="Specification Win Rate" name="name3" id="tabThree">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="1">
                    <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                    <apex:inputField value="{!account.Specifications_Won__c}"/>
                    <apex:inputField value="{!account.Specifications_Lost__c}"/>
                    <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
    </apex:tabPanel>
</apex:page>
Thanks in advance!
 

I have created an apex trigger to share a custom object record based on user lookup fields.  Works great on the initial load of the record.  Here are a couple of things I would like to have happen.

 

1.  When one of the user lookup fields change to remove the person that had sharing access before.

2.  Grant sharing access to the new user.

 

I don't know if this makes a difference but, all creation of new records and updates are being done through an informatica cloud integration.  Users are not adding records modifying the user lookup fields.  Any assistance would be greatly appreciated!

 

Below is my current code:

 

trigger TeamMemberAccess on Quote__c (after insert,after update) {
    
    if(trigger.isInsert){
        // Create a new list of sharing objects for Quote 
    
        List<Quote__Share> quoteShrs  = new List<Quote__Share>();
        
        // Declare variables for specifying rep, purchasing rep, and ap rep sharing 
    
        Quote__Share specifyingShr;
        Quote__Share purchasingShr;
        Quote__Share apShr;
        
        for(Quote__c quote : trigger.new){
            // Instantiate the sharing objects 
    
            specifyingShr = new Quote__Share();
            purchasingShr = new Quote__Share();
            apShr = new Quote__Share();
            
            // Set the ID of record being shared 
    
            specifyingShr.ParentId = quote.Id;
            purchasingShr.ParentId = quote.Id;
            apShr.ParentId = quote.Id;
            
            // Set the ID of user or group being granted access 
    
            specifyingShr.UserOrGroupId = quote.specifying_rep__c;
            purchasingShr.UserOrGroupId = quote.purchasing_rep__c;
            apShr.UserOrGroupId = quote.ap_rep1__c;
            
            // Set the access level 
    
            specifyingShr.AccessLevel = 'edit';
            purchasingShr.AccessLevel = 'edit';
            apShr.AccessLevel = 'edit';
            
            // Set the Apex sharing reason for specifying rep, purchasing rep, and ap rep 
    
            specifyingShr.RowCause = Schema.Quote__Share.RowCause.specifying_rep__c;
            purchasingShr.RowCause = Schema.Quote__Share.RowCause.purchasing_rep__c;
            apShr.RowCause = Schema.Quote__Share.RowCause.ap_rep__c;
            
            // Add objects to list for insert 
    
            quoteShrs.add(specifyingShr);
            quoteShrs.add(purchasingShr);
            quoteShrs.add(apShr);
        }
        
        // Insert sharing records and capture save result  
    
        // The false parameter allows for partial processing if multiple records are passed  
    
        // into the operation  
    
        Database.SaveResult[] lsr = Database.insert(quoteShrs,false);
        
        // Create counter 
    
        Integer i=0;
        
        // Process the save results 
    
        for(Database.SaveResult sr : lsr){
            if(!sr.isSuccess()){
                // Get the first save result error 
    
                Database.Error err = sr.getErrors()[0];
                
                // Check if the error is related to a trivial access level 
    
                // Access levels equal or more permissive than the object's default  
    
                // access level are not allowed.  
    
                // These sharing records are not required and thus an insert exception is  
    
                // acceptable.  
    
                if(!(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  
                                               &&  err.getMessage().contains('AccessLevel'))){
                    // Throw an error when the error is not related to trivial access level. 
    
                    trigger.newMap.get(quoteShrs[i].ParentId).
                      addError(
                       'Unable to grant sharing access due to following exception: '
                       + err.getMessage());
                }
            }
            i++;
        }   
    }
    
}

Using some examples I have come up with the following Visualforce page on our accounts.  I have a few issue with it that I need some help on.
  1. The page is cut off at the bottom when added to the Account Details page.
  2. Clicking the Save button in the page does save the inputField changes but it tries to display the entire Salesforce.com window in the Apex page.
  3. Is there a way to only display this based on a checkbox being checked?
<apex:page standardController="Account" showHeader="true">
    <!-- Define Tab panel .css styles -->
    <style>
    .activeTab {background-color: #236FBD; color:white; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
            
    <!-- Create Tab panel -->
    <apex:tabPanel switchType="client" selectedTab="name1" id="AccountTabPanel"
        tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Contact Penetration" name="name1" id="tabOne">
               <apex:pageBlock >
                  <apex:pageBlockSection columns="3">
                    <apex:outputField value="{!account.Architect_Contacts__c}"/>
                    <apex:outputField value="{!account.Design_Contacts__c}"/>
                    <apex:outputField value="{!account.Total_Contacts__c}"/>
                    <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Architect_Penetration__c}"/>
                    <apex:outputField value="{!account.Design_Penetration__c}"/>
                    <apex:outputField value="{!account.Total_Penetration__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
        </apex:tab>
        <apex:tab label="Specification Share of Wallet" name="name2" id="tabTwo">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="2">
                    <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                    <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
        <apex:tab label="Specification Win Rate" name="name3" id="tabThree">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="1">
                    <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                    <apex:inputField value="{!account.Specifications_Won__c}"/>
                    <apex:inputField value="{!account.Specifications_Lost__c}"/>
                    <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
    </apex:tabPanel>
</apex:page>
Thanks in advance!
 

We have a formula field that calculates the number of hours since a record was created vs. now

((NOW() - CreatedDate)*24)

I would like to modify this to only include business hours, Monday through Friday 8-5 Eastern and to no include weekends.
Any suggestions or direction would be appreciated.

Thanks,
Stacey

I borrowed some apex code to develop a editable related contact on an account visual force page.  I need to limit the related contact list to those not marked as inactive.  What code would need to be added to achieve this result?
 
/*
 * EditableContactListExtension.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   This is the implementation class where Object specific references
 *   need to be defined. Please see EditableList.cls for more information
 *   on what each method is responsible for.
 *
 *   Required methods:
 *     - EditableContactListExtension(ApexPages.StandardController)
 *     - getChildren()
 *     - initChildRecord()
 *
 */
public with sharing class EditableContactListExtension extends EditableList
{
  // Read the explanation in EditableContactListExtension(ApexPages.StandardController)
  // to see when to uncomment the following line.

  // public Account myAccount {get; private set;}

public ApexPages.StandardController controller {get;set;}

  public EditableContactListExtension(ApexPages.StandardController stdController) 
  {
    super(stdController);
    controller = stdController;

    // If necessary, explicitly query for additional metadata on parent record
    // if you are looking to display things that don't come back with the
    // StandardController. In that case, you will need to replace the "Account.X"
    // references in the Visualforce Page with references to an Account variable
    // that you will need to declare in this class (myAccount.X). I have commented out
    // an example.

    // this.myAccount = [SELECT Id,
    //                            Name,
    //                            Custom_Relationship__r.Name
    //                        FROM Account
    //                        WHERE Id =: stdController.getRecord().Id];
    
    this.childList = [SELECT Id,
                          FirstName,
                          LastName,
                          Studio__c,
                          Type__c,
                          Preferred_Contact_Frequency__c,
                          Date_Last_Contacted__c,
                          Days_Since_Contact__c
                      FROM Contact
                      WHERE AccountId =: mysObject.Id
                      ORDER BY Contact.FirstName ASC];
  }

  /*
   * This method is necessary for reference on the Visualforce page, 
   * in order to reference non-standard fields.
   */
  public List<Contact> getChildren()
  {
    return (List<Contact>)childList;
  }

  public override sObject initChildRecord()
  {
    Contact child = new Contact();
    // Can either use mysObject or acct here
    child.AccountId = mysObject.Id;
    
    return child;
  }

  public PageReference saveAll()
  {
    super.save();
    return controller.save();
  }
}
Thanks in advance!
 
I borrowed some code from the internet and now I cannot deploy it due to a code coverage error.  Is there any way around this or to fix it?
I am new to developing and I am having an issue with one of my test classes.  Can someone look it over and tell me what is wrong with it.  Here is the error I get when trying to deploy.

EditableList_Test.test_save_failure(), Details: System.AssertException: Assertion Failed: Expected: 1, Actual: 2 Class.EditableList_Test.test_save_failure: line 193, column 1

Here is the code for EditableList_Test
 
/*
 * EditableList_Test.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   Test class for EditableList.cls
 *
 */
@isTest
private class EditableList_Test 
{   
  /*
   * Mock implementation of abstract class used for testing
   */
    private class MockEditableList extends EditableList
  {
    public MockEditableList(ApexPages.StandardController stdController)
    {
      super(stdController);
    } 
  }

  private static Account acct;
  private static Contact myContact1;
  private static Contact myContact2;

  private static void setupData()
  {
    acct = new Account();
    acct.Name = 'Test Account 1';
    insert acct;

    myContact1 = new Contact();
    myContact1.LastName = 'Smith';
    myContact1.AccountId = acct.Id;
    insert myContact1;

    myContact2 = new Contact();
    myContact2.LastName = 'Smith';
    myContact2.AccountId = acct.Id;
    insert myContact2;
  }
    
    @isTest static void test_EditableList() 
  {
        setupData();

    Test.startTest();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    Test.stopTest();

    System.assertEquals(0, mock.ZERO);
    System.assertEquals(0, mock.childList.size());
    System.assertEquals(0, mock.removeChildList.size());
    }
    
  @isTest static void test_getHasChildren()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    Test.startTest();

    System.assertEquals(false, mock.getHasChildren());

    mock.childList.add(new Contact());

    System.assertEquals(true, mock.getHasChildren());

    Test.stopTest();
  }

  @isTest static void test_initChildRecord()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    Test.startTest();

    System.assert(mock.initChildRecord() instanceof Contact);
    
    Test.stopTest();
  }

  @isTest static void test_addToList()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    System.assertEquals(0, mock.childList.size());

    Test.startTest();

    mock.addToList();

    Test.stopTest();

    System.assertEquals(1, mock.childList.size());
  }

  @isTest static void test_removeFromList()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    mock.childList.add(myContact1);
    mock.childList.add(myContact2);

    Test.startTest();

    mock.removeIndex = '1';
    mock.removeFromList();

    Test.stopTest();

    System.assertEquals(1, mock.childList.size());
    System.assertEquals(myContact2.Id, mock.childList[0].Id);
    System.assertEquals(1, mock.removeChildList.size());
    System.assertEquals(myContact1.Id, mock.removeChildList[0].Id);
  }

  @isTest static void test_getSuccessURL_param()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    String retURL = '/test';
    PageReference pr = new PageReference('/');
    pr.getParameters().put('retURL', retURL);

    Test.setCurrentPageReference(pr);
    Test.startTest();

    System.assertEquals(retURL, mock.getSuccessURL().getUrl());

    Test.stopTest();
  }

  @isTest static void test_getSuccessURL_noParam()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    PageReference pr = new PageReference('/');

    Test.setCurrentPageReference(pr);
    Test.startTest();

    System.assertEquals(std.view().getUrl(), mock.getSuccessURL().getUrl());

    Test.stopTest();
  }

  @isTest static void test_save_failure()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    mock.childList.add(myContact1);
    mock.removeChildList.add(myContact2);

    // Purposely leave out required LastName
    Contact newContact = new Contact();
    newContact.AccountId = acct.Id;

    mock.childList.add(newContact);

    Test.startTest();

    System.assertEquals(null, mock.save());

    Test.stopTest();

    System.assertEquals(1, ApexPages.getMessages().size());
    System.assertEquals(ApexPages.Severity.ERROR, ApexPages.getMessages()[0].getSeverity());
    
  }

  @isTest static void test_save_success()
  {
    setupData();

    ApexPages.StandardController std = new ApexPages.StandardController(acct);
    MockEditableList mock = new MockEditableList(std);

    mock.childList.add(myContact1);
    mock.removeChildList.add(myContact2);

    Contact newContact = new Contact();
    newContact.LastName = 'Test';
    newContact.AccountId = acct.Id;

    mock.childList.add(newContact);

    Test.startTest();

    System.assertEquals(mock.getSuccessURL().getUrl(), mock.save().getUrl());

    Test.stopTest();

    List<sObject> results = [SELECT Id FROM Contact WHERE AccountId =: acct.Id ORDER BY CreatedDate];
    System.assertEquals(2, results.size());
    System.assertEquals(myContact1.Id, results[0].Id);
    System.assertNotEquals(myContact2.Id, results[1].Id);
  }
}

 
I created a visual force page with Account Details at the top and a contact related list at the bottom.  I have Save and Cancel buttons on the page.  The Save button works after I modify a contact but does not save the modification when I change one of the account fields.  Here is my code.

---VF Page---
<apex:page standardController="Account" showHeader="true" sidebar="true" extensions="EditableContactListExtension">
    <apex:form >  
      <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Account Penetration" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                <apex:commandButton value="Print Profile" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()"/>
                <Script Language="JavaScript">function openConga() { window.open('{!URLFOR($Action.Account.Penetration_Profile,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); }  
                </Script>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Contact Penetration" columns="3">
                <apex:outputField value="{!account.Architect_Contacts__c}"/>
                <apex:outputField value="{!account.Design_Contacts__c}"/>
                <apex:outputField value="{!account.Total_Contacts__c}"/>
                <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Architect_Penetration__c}"/>
                <apex:outputField value="{!account.Design_Penetration__c}"/>
                <apex:outputField value="{!account.Total_Penetration__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Share of Wallet" columns="2">
                <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Win Rate" columns="1">
                <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                <apex:inputField value="{!account.Specifications_Won__c}"/>
                <apex:inputField value="{!account.Specifications_Lost__c}"/>
                <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection id="childList" columns="1" title="Known Contacts" collapsible="false">
        	  <!-- There is a trick to creating a counter when rendering rows in a
              pageBlockTable. You have to define a variable to default to 0,
              and then update that variable inside the table row. This is the
              way that I can leverage smart row deletes -->
        <apex:variable var="rowNum" value="{!ZERO}" />
        <apex:outputLabel value="No Contacts currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/>
        <apex:pageBlockTable value="{!children}" var="contact" rendered="{!hasChildren}" >
          <apex:column headerValue="First Name">
            <apex:inputField value="{!contact.FirstName}" />
          </apex:column>
          <apex:column headerValue="Last Name">
            <apex:inputField value="{!contact.LastName}" />
          </apex:column>
            <!-- Add additional children metadata columns here -->
          <apex:column headerValue="Studio">
            <apex:inputField value="{!contact.Studio__c}" />
          </apex:column>
          <apex:column headerValue="Type">
            <apex:inputField value="{!contact.Type__c}" />
          </apex:column>
          <apex:column headerValue="Preferred Contact Frequency">
            <apex:inputField value="{!contact.Preferred_Contact_Frequency__c}" />
          </apex:column>
          <apex:column headerValue="Date Last Contacted">
            <apex:inputField value="{!contact.Date_Last_Contacted__c}" />
          </apex:column>
          <apex:column headerValue="Days Since Contact">
            <apex:inputField value="{!contact.Days_Since_Contact__c}" />
          </apex:column>  
            <!-- This is the second half of the trick to keep track
                  of your row index for deletion. -->
            <apex:variable var="rowNum" value="{!rowNum + 1}" />
            <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList, messages" immediate="true">
              <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" />
            </apex:commandLink>
        </apex:pageBlockTable>
        <!-- Want to specify immediate here and above so validation does
              not occur when you are trying to add/remove rows. Only want
              validation to occur when trying to save -->
        <apex:commandButton value="Add Contact" action="{!addToList}" rerender="childList, messages" immediate="true" />
      	</apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>
Thanks!
Using some examples I have come up with the following Visualforce page on our accounts.  I have a few issue with it that I need some help on.
  1. The page is cut off at the bottom when added to the Account Details page.
  2. Clicking the Save button in the page does save the inputField changes but it tries to display the entire Salesforce.com window in the Apex page.
  3. Is there a way to only display this based on a checkbox being checked?
<apex:page standardController="Account" showHeader="true">
    <!-- Define Tab panel .css styles -->
    <style>
    .activeTab {background-color: #236FBD; color:white; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
            
    <!-- Create Tab panel -->
    <apex:tabPanel switchType="client" selectedTab="name1" id="AccountTabPanel"
        tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Contact Penetration" name="name1" id="tabOne">
               <apex:pageBlock >
                  <apex:pageBlockSection columns="3">
                    <apex:outputField value="{!account.Architect_Contacts__c}"/>
                    <apex:outputField value="{!account.Design_Contacts__c}"/>
                    <apex:outputField value="{!account.Total_Contacts__c}"/>
                    <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Architect_Penetration__c}"/>
                    <apex:outputField value="{!account.Design_Penetration__c}"/>
                    <apex:outputField value="{!account.Total_Penetration__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
        </apex:tab>
        <apex:tab label="Specification Share of Wallet" name="name2" id="tabTwo">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="2">
                    <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                    <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
        <apex:tab label="Specification Win Rate" name="name3" id="tabThree">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="1">
                    <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                    <apex:inputField value="{!account.Specifications_Won__c}"/>
                    <apex:inputField value="{!account.Specifications_Lost__c}"/>
                    <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
    </apex:tabPanel>
</apex:page>
Thanks in advance!