• Charles Thompson
  • NEWBIE
  • 20 Points
  • Member since 2017
  • Program Architect
  • Salesforce Singapore


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 15
    Replies
User-added image
I have come up with a way to replace Classic related lists on a page layout, so you can get past some of the limitations of page layouts. I hope this post will be helpful to our global ohana.

Why would you want to do this?
Related Lists can only have up to 10 columns.  My customer has a related custom object with 14 fields that should be displayed on a single line:  Year, Jan ... Dec, and Year Total.  Each monthly value is a currency field, and multi-currency is on for the Org, meaning that the currency ISO code is displayed for each of these fields.  So we also want to display the values without the ISO code.

What did I do to get around this?
My solution includes two Visualforce (VF) pages and a controller extension.
  1. View page:  A page thatdisplays the fields in a table, as read-only. On this page is a single button, [Edit] to switch to Edit mode.
  2. Edit page: A page that displays the fields in a table, as editable fields. It has three buttons: [Add] [Save] [Cancel]
  3. Apex controller extension. I used an extension because it adds to the functionality of the standard controller, which could be helpful in more complex use cases.
In my example, I have a new custom object, Budget, related to Contact in a master/detail relationship. I declined to put the related list on the Contact page layouts because I added my own VF page to the layout details section.  If you want to duplicate my code exactly in your DevEd org, you'll need to create this object and relate it to Contact.

Apex Controller Extension (BudgetExt.apxc):
public with sharing class BudgetExt {
    
/*************************************************
 * Controller extension to provide functionality required for the Budgets
 * section of Contact detail page.  The business requirement was to allow
 * the Budgets related list on Contact to display 14 columns (year
 * + 12 months + total).  The end result is an embedded VF page component on the Contact
 * page layout that displays the Budget related rows in view mode 
 * (read only), with an edit button local to the component.  Clicking Edit 
 * switches the component to Edit Mode by changing the PageReference to
 * the related Edit mode VF page.  On that page are three buttons (Add Row, 
 * Save and Cancel) plus a Delete button on each row.  Hitting Save or Cancel
 * brings you back to the View mode page.
 * 
 * Related VF pages:
 * - BudgetEdit.vfp
 * - BudgetView.vfp
 * 
 * Author: Charles Thompson, Salesforce, Nov 2017
 * *************************************************/
    
    private final Id contactID; // store the parent (Contact) ID
    public Integer index {get;set;} // store the current row being deleted
    
    // List to represent each row of the pageBlockTable of Budgets 
    // related to the parent Sub Project
    public List<Budget__c> budgets {get; set;}

    // List to hold those rows being deleted
    public List<Budget__c> budgetsToDel = new List<Budget__c>();
    
    // Variable to hold the Sub Project (parent) record
    public Contact theContact {get; set;}
    
    // Initial load of the pageBlockTable
    public BudgetExt(ApexPages.StandardController stdController){
        contactID = stdController.getId();
        this.index = 0;
        theContact = [SELECT Id
                      FROM   Contact
                      WHERE  Id = :contactID
                      LIMIT 1
                     ];
        budgets =    [SELECT Id,
                             Year__c,
                               Jan__c, Feb__c, Mar__c, Apr__c,
                               May__c, Jun__c, Jul__c, Aug__c,
                              Sep__c, Oct__c, Nov__c, Dec__c,
                             Year_Total__c
                      FROM   Budget__c
                      WHERE  Contact__c = :contactID
               ORDER BY Year__c
              ];
    }
                              
    public String getIndex(){
        return String.valueOf(index);
    }
    
    public void setIndex(String indexIn){
        this.index = Integer.valueOf(indexIn);
    }
            
    // Add an empty budget row to the table 
    // (not saved to the database until saveBuds() is called)
    public void addRow(){
        Budget__c row = new Budget__c();
        row.Contact__c = contactID;
        budgets.add(row); 
    }
    
    // delete a forecast from the table (not saved to the db until later)
    public void delRow(){
        
        Integer i = this.index-1; // Rows start at one, Lists start at zero
        
        // If the row is an existing row then add it to the list 
        // to delete from the database
        if (budgets[i].Id != null){
            budgetsToDel.add(budgets[i]);
        }
        //Remove the forecast from the table    
        budgets.remove(i);
    }
    
    public PageReference saveBuds(){
        // update and insert forecasts as per the current list
        upsert budgets;
        
        // delete any rows in the list of deletions
        if ((budgetsToDel != null) && (budgetsToDel.size() > 0)){
            delete budgetsToDel;
        }
        
        return cancelEdit();
    }
    
    public PageReference editBuds(){
        // switch to Edit mode
        PageReference editPage = new PageReference('/apex/BudgetEdit?id=' + contactID);
        return editPage;
    }

    public PageReference cancelEdit(){
        // switch back to View mode without saving anything
        PageReference viewPage = new PageReference('/apex/BudgetView?id=' + contactID);
        viewPage.setRedirect(true);
        return viewPage;
    }   
}

View VF page (BudgetView.vfp):
<apex:page standardController="Contact" extensions="BudgetExt">
<!------------------------------------------------------------------------ 
    This page is designed to fit as a component on the detail page of 
    the Contact page layout.  This is the View Mode version of the page, 
    containing output fields and a button for Edit.
    
    Note that the currency ISO code doesn't appear and is assumed to be 
    carried through from the parent record.
     
    The related Edit Mode page is called "BudgetEdit".
     
    Author: Charles Thompson, Salesforce Singapore, Nov 2017 
--------------------------------------------------------------------------> 

    <apex:form >
        <apex:pageBlock mode="maindetail">

            <table width="100%">
                <tr>
                    <td style="text-align:center">
                        <!-- Button... Edit (switch to Edit Mode) -->
                        <apex:commandButton value="Edit" action="{!editBuds}" 
                                            id="editButton" />
                    </td>
                </tr>
            </table>
            
            <!-- Table displaying the Annual Forecast related records -->
            <apex:pageBlockTable value="{!budgets}" var="row" id="budgetTbl" >
            
                <apex:column headerValue="Year">
                    <apex:outputText id="Year" value="{!row.Year__c}" style="width:40px" />
                </apex:column>
 
                 <!-- Currency fields from Budget (formatted as number without currency) -->               
                <apex:column headerValue="Jan" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Jan" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Jan__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Feb" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Feb" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Feb__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Mar" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Mar" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Mar__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Apr" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Apr" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Apr__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="May" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="May" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.May__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Jun" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Jun" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Jun__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Jul" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Jul" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Jul__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Aug" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Aug" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Aug__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Sep" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Sep" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Sep__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Oct" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Oct" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Oct__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Nov" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Nov" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Nov__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Dec" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Dec" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Dec__c}"/>
                    </apex:outputText>
                </apex:column>
                
                <!-- Total (sum) for the year -->
                <apex:column headerValue="Total" style="text-align:right" 
                             headerClass="CurrencyElement" >
                    <apex:outputText id="yearTotal" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Year_Total__c}"/>
                    </apex:outputText>
               </apex:column>

            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>

</apex:page>

Edit VF page (BudgetEdit.vfp):
<apex:page id="thepage" standardController="Contact" extensions="BudgetExt">
<!------------------------------------------------------------------------ 
    This page is designed to fit as a component on the detail page of 
    the Contact page layout.  This is the Edit Mode version of the page, 
    containing input fields and buttons for Add Row, Save, Cancel and Delete.
    
    Note that the currency ISO code doesn't appear and is assumed to be 
    carried through from the parent record.
     
    The related View Mode page is called "BudgetView".
     
    Author: Charles Thompson, Salesforce Singapore, Nov 2017 
--------------------------------------------------------------------------> 
    <apex:form>
        <apex:pageBlock mode="maindetail">

            <table width="100%">
                <tr>
                    <td style="text-align:center">
                        <!-- Buttons... Add Row / Save / Cancel -->
                        <apex:commandButton value="Add Row" action="{!addRow}" 
                                            id="addButton" />
                        <apex:commandButton value="Save" action="{!saveBuds}" 
                                            id="saveButton" />
                        <apex:commandButton value="Cancel" action="{!cancelEdit}" 
                                            id="cancelButton" />
                    </td>
                </tr>
            </table>
            
            <!-- Table displaying the related records -->
            <apex:pageBlockTable value="{!budgets}" var="row" id="budgets" >

                <!-- Counter variable to store an index value for each line -->
                <apex:variable var="i" value="{!0}" />
                <!-- Delete button -->
                <apex:column >
                    <apex:commandButton value="X" style="color: red" 
                                        action="{!delRow}" reRender="budgets"
                                        immediate="true" >
                        <!-- populate Apex index variable -->
                        <apex:param name="index" value="{!i}" assignTo="{!index}"/> 
                    </apex:commandButton>
                    <apex:variable var="i" value="{!i + 1}" />
                </apex:column>
                <apex:column headerValue="Year" 
                             title="Enter the forecast by month for this year and next year">
                    <apex:inputField value="{!row.Year__c}" style="width:60px"  />
                </apex:column>
 
                 <!-- Currency fields from Annual Forecast (the currency indicator doesn't appear) -->               
                <apex:column headerValue="Jan" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Jan__c}" 
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Feb" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Feb__c}" 
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Mar" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Mar__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Apr" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Apr__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="May" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.May__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Jun" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Jun__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Jul" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Jul__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Aug" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Aug__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Sep" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Sep__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Oct" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Oct__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Nov" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Nov__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Dec" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Dec__c}"  
                                     style="text-align:right; width:65px" />
               </apex:column>
                <!-- Total (sum) for the year -->
                <apex:column headerValue="Total" style="text-align:right" 
                             headerClass="CurrencyElement" >
                    <apex:outputText id="yearTotal" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Year_Total__c}"/>
                    </apex:outputText>
               </apex:column>

            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>

</apex:page>

I hope this helps someone in the future, even if Lightning Experience makes this solution somewhat useless.
 
User-added image
I have come up with a way to replace Classic related lists on a page layout, so you can get past some of the limitations of page layouts. I hope this post will be helpful to our global ohana.

Why would you want to do this?
Related Lists can only have up to 10 columns.  My customer has a related custom object with 14 fields that should be displayed on a single line:  Year, Jan ... Dec, and Year Total.  Each monthly value is a currency field, and multi-currency is on for the Org, meaning that the currency ISO code is displayed for each of these fields.  So we also want to display the values without the ISO code.

What did I do to get around this?
My solution includes two Visualforce (VF) pages and a controller extension.
  1. View page:  A page thatdisplays the fields in a table, as read-only. On this page is a single button, [Edit] to switch to Edit mode.
  2. Edit page: A page that displays the fields in a table, as editable fields. It has three buttons: [Add] [Save] [Cancel]
  3. Apex controller extension. I used an extension because it adds to the functionality of the standard controller, which could be helpful in more complex use cases.
In my example, I have a new custom object, Budget, related to Contact in a master/detail relationship. I declined to put the related list on the Contact page layouts because I added my own VF page to the layout details section.  If you want to duplicate my code exactly in your DevEd org, you'll need to create this object and relate it to Contact.

Apex Controller Extension (BudgetExt.apxc):
public with sharing class BudgetExt {
    
/*************************************************
 * Controller extension to provide functionality required for the Budgets
 * section of Contact detail page.  The business requirement was to allow
 * the Budgets related list on Contact to display 14 columns (year
 * + 12 months + total).  The end result is an embedded VF page component on the Contact
 * page layout that displays the Budget related rows in view mode 
 * (read only), with an edit button local to the component.  Clicking Edit 
 * switches the component to Edit Mode by changing the PageReference to
 * the related Edit mode VF page.  On that page are three buttons (Add Row, 
 * Save and Cancel) plus a Delete button on each row.  Hitting Save or Cancel
 * brings you back to the View mode page.
 * 
 * Related VF pages:
 * - BudgetEdit.vfp
 * - BudgetView.vfp
 * 
 * Author: Charles Thompson, Salesforce, Nov 2017
 * *************************************************/
    
    private final Id contactID; // store the parent (Contact) ID
    public Integer index {get;set;} // store the current row being deleted
    
    // List to represent each row of the pageBlockTable of Budgets 
    // related to the parent Sub Project
    public List<Budget__c> budgets {get; set;}

    // List to hold those rows being deleted
    public List<Budget__c> budgetsToDel = new List<Budget__c>();
    
    // Variable to hold the Sub Project (parent) record
    public Contact theContact {get; set;}
    
    // Initial load of the pageBlockTable
    public BudgetExt(ApexPages.StandardController stdController){
        contactID = stdController.getId();
        this.index = 0;
        theContact = [SELECT Id
                      FROM   Contact
                      WHERE  Id = :contactID
                      LIMIT 1
                     ];
        budgets =    [SELECT Id,
                             Year__c,
                               Jan__c, Feb__c, Mar__c, Apr__c,
                               May__c, Jun__c, Jul__c, Aug__c,
                              Sep__c, Oct__c, Nov__c, Dec__c,
                             Year_Total__c
                      FROM   Budget__c
                      WHERE  Contact__c = :contactID
               ORDER BY Year__c
              ];
    }
                              
    public String getIndex(){
        return String.valueOf(index);
    }
    
    public void setIndex(String indexIn){
        this.index = Integer.valueOf(indexIn);
    }
            
    // Add an empty budget row to the table 
    // (not saved to the database until saveBuds() is called)
    public void addRow(){
        Budget__c row = new Budget__c();
        row.Contact__c = contactID;
        budgets.add(row); 
    }
    
    // delete a forecast from the table (not saved to the db until later)
    public void delRow(){
        
        Integer i = this.index-1; // Rows start at one, Lists start at zero
        
        // If the row is an existing row then add it to the list 
        // to delete from the database
        if (budgets[i].Id != null){
            budgetsToDel.add(budgets[i]);
        }
        //Remove the forecast from the table    
        budgets.remove(i);
    }
    
    public PageReference saveBuds(){
        // update and insert forecasts as per the current list
        upsert budgets;
        
        // delete any rows in the list of deletions
        if ((budgetsToDel != null) && (budgetsToDel.size() > 0)){
            delete budgetsToDel;
        }
        
        return cancelEdit();
    }
    
    public PageReference editBuds(){
        // switch to Edit mode
        PageReference editPage = new PageReference('/apex/BudgetEdit?id=' + contactID);
        return editPage;
    }

    public PageReference cancelEdit(){
        // switch back to View mode without saving anything
        PageReference viewPage = new PageReference('/apex/BudgetView?id=' + contactID);
        viewPage.setRedirect(true);
        return viewPage;
    }   
}

View VF page (BudgetView.vfp):
<apex:page standardController="Contact" extensions="BudgetExt">
<!------------------------------------------------------------------------ 
    This page is designed to fit as a component on the detail page of 
    the Contact page layout.  This is the View Mode version of the page, 
    containing output fields and a button for Edit.
    
    Note that the currency ISO code doesn't appear and is assumed to be 
    carried through from the parent record.
     
    The related Edit Mode page is called "BudgetEdit".
     
    Author: Charles Thompson, Salesforce Singapore, Nov 2017 
--------------------------------------------------------------------------> 

    <apex:form >
        <apex:pageBlock mode="maindetail">

            <table width="100%">
                <tr>
                    <td style="text-align:center">
                        <!-- Button... Edit (switch to Edit Mode) -->
                        <apex:commandButton value="Edit" action="{!editBuds}" 
                                            id="editButton" />
                    </td>
                </tr>
            </table>
            
            <!-- Table displaying the Annual Forecast related records -->
            <apex:pageBlockTable value="{!budgets}" var="row" id="budgetTbl" >
            
                <apex:column headerValue="Year">
                    <apex:outputText id="Year" value="{!row.Year__c}" style="width:40px" />
                </apex:column>
 
                 <!-- Currency fields from Budget (formatted as number without currency) -->               
                <apex:column headerValue="Jan" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Jan" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Jan__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Feb" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Feb" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Feb__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Mar" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Mar" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Mar__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Apr" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Apr" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Apr__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="May" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="May" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.May__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Jun" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Jun" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Jun__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Jul" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Jul" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Jul__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Aug" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Aug" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Aug__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Sep" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Sep" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Sep__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Oct" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Oct" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Oct__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Nov" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Nov" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Nov__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column headerValue="Dec" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:outputText id="Dec" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Dec__c}"/>
                    </apex:outputText>
                </apex:column>
                
                <!-- Total (sum) for the year -->
                <apex:column headerValue="Total" style="text-align:right" 
                             headerClass="CurrencyElement" >
                    <apex:outputText id="yearTotal" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Year_Total__c}"/>
                    </apex:outputText>
               </apex:column>

            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>

</apex:page>

Edit VF page (BudgetEdit.vfp):
<apex:page id="thepage" standardController="Contact" extensions="BudgetExt">
<!------------------------------------------------------------------------ 
    This page is designed to fit as a component on the detail page of 
    the Contact page layout.  This is the Edit Mode version of the page, 
    containing input fields and buttons for Add Row, Save, Cancel and Delete.
    
    Note that the currency ISO code doesn't appear and is assumed to be 
    carried through from the parent record.
     
    The related View Mode page is called "BudgetView".
     
    Author: Charles Thompson, Salesforce Singapore, Nov 2017 
--------------------------------------------------------------------------> 
    <apex:form>
        <apex:pageBlock mode="maindetail">

            <table width="100%">
                <tr>
                    <td style="text-align:center">
                        <!-- Buttons... Add Row / Save / Cancel -->
                        <apex:commandButton value="Add Row" action="{!addRow}" 
                                            id="addButton" />
                        <apex:commandButton value="Save" action="{!saveBuds}" 
                                            id="saveButton" />
                        <apex:commandButton value="Cancel" action="{!cancelEdit}" 
                                            id="cancelButton" />
                    </td>
                </tr>
            </table>
            
            <!-- Table displaying the related records -->
            <apex:pageBlockTable value="{!budgets}" var="row" id="budgets" >

                <!-- Counter variable to store an index value for each line -->
                <apex:variable var="i" value="{!0}" />
                <!-- Delete button -->
                <apex:column >
                    <apex:commandButton value="X" style="color: red" 
                                        action="{!delRow}" reRender="budgets"
                                        immediate="true" >
                        <!-- populate Apex index variable -->
                        <apex:param name="index" value="{!i}" assignTo="{!index}"/> 
                    </apex:commandButton>
                    <apex:variable var="i" value="{!i + 1}" />
                </apex:column>
                <apex:column headerValue="Year" 
                             title="Enter the forecast by month for this year and next year">
                    <apex:inputField value="{!row.Year__c}" style="width:60px"  />
                </apex:column>
 
                 <!-- Currency fields from Annual Forecast (the currency indicator doesn't appear) -->               
                <apex:column headerValue="Jan" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Jan__c}" 
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Feb" style="text-align:right" 
                             headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Feb__c}" 
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Mar" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Mar__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Apr" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Apr__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="May" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.May__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Jun" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Jun__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Jul" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Jul__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Aug" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Aug__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Sep" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Sep__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Oct" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Oct__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Nov" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Nov__c}"  
                                     style="text-align:right; width:65px" />
                </apex:column>
                <apex:column headerValue="Dec" style="text-align:right"  
                                     headerClass="CurrencyElement">
                    <apex:inputField value="{!row.Dec__c}"  
                                     style="text-align:right; width:65px" />
               </apex:column>
                <!-- Total (sum) for the year -->
                <apex:column headerValue="Total" style="text-align:right" 
                             headerClass="CurrencyElement" >
                    <apex:outputText id="yearTotal" value="{0, number, ###,###,##0}" >
                        <apex:param value="{!row.Year_Total__c}"/>
                    </apex:outputText>
               </apex:column>

            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>

</apex:page>

I hope this helps someone in the future, even if Lightning Experience makes this solution somewhat useless.
 
I've added all these line of code in the Save() method to try to satisfy the "Modify the save() function to implement CRUD/FLS check on the Name field of the Encrypt_Decrypt__c object." requirement but nothing seems to pass it's check.  Anyone else run into this or have any ideas?

        if (!Schema.sObjectType.EnCrypt_Decrypt__c.fields.Name.isCreateable()) { 
            return NULL; 
        }
        if (!Schema.sObjectType.EnCrypt_Decrypt__c.fields.Name.isUpdateable()) { 
            return NULL; 
        }        
        if (!Schema.sObjectType.EnCrypt_Decrypt__c.fields.Name.isAccessible()) { 
            return NULL; 
        }        

Thanks,
Deb
Hi,
I am having trouble with the Trailhead project Build a Community with Knowledge and Chat, specfically the Enable and Configure Lightning Knowledge. The badge says to create a Knowledge Record Type of 'FAQ'. I do not see anywhere, where you can create a Record Type for the Knowledge Object.

There are Knowledge Article types, which have the fields that are displayed in the example. But there is no way to create a Record Type for them.

I can create Record Types for the Linked Articles, which I did, but when I verify this step, the error message comes back and says:
Challenge Not yet complete... here's what's wrong: 
Could not find a Knowledge recordtype named 'FAQ'.

Am I doing this correctly or are there issues with this Trail due to Summer '17? It's a brand new badge, so it must be me.

Thanks!
I'm currently workng my way through Explore Custom Transaction Security Policies : Test the Apex for the Policy.
Perhaps at the time this module was written, the example code was valid.

However, presently: 
1. If I try to set the value of LoginHistory.platform, the Apex code is rejected with 
Error: Compile Error: Field is not writeable: LoginHistory.Platform at line 6 column 5

2. If I try to insert a LoginHistory record, the Apex code is rejected with
Error: Compile Error: DML operation INSERT not allowed on LoginHistory at line 7 column 5

I don't want to litter my production code with Test.isRunningTest().

While I could refactor the code to replace both the SOQL and the evaluation with injected dependency(s), such would leave the most critical portions of the class actually untested, which is likewise unsatisfactory.

Is it still possible to test the PolicyCondition?
Is there some trick I'm overlooking?





 
For whatever reason the Lightning app built during the above Trailhead project does not work when previewed.  I keep getting this error:

This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined]

No issues with the project chanllenges, in fact I have completed the project trail.  Checked my code, exact same as given during the project steps.
Hi

How to generate a batch class that is generic that
 can accept all the sObjects and some criteria?
@AuraEnabled
public static List<Contact> getContacts() {
    return [Select Id, Name, Email, Title, Phone From Contact];
}
I'm receiving the following error: unexpected token: 'List'
 
I am unable to view the results on Preview.
The list of contacts is not  being diaplyed
I was solving this challenge and my VF code is:

<apex:page standardController="Account" recordSetVar="Accounts" >
    <apex:pageblock>
        <apex:repeat var="a" value="{!Accounts}" rendered="true"  id="account_list">
            <li>
                <apex:outputLink value="https://ap1.salesforce.com/{!a.ID}" >
                    <apex:outputText value="{!a.Name}"/>
                </apex:outputLink>
            </li>
        </apex:repeat>
    </apex:pageblock>
</apex:page>

I am getting the list of accounts as required and on clicking on any of the accouts, it redirects to that accounts detail page.
Still I am getting following error from trailhead:

"The page does not bind to the record ID value (in order to link to the record detail page)"

 The use case is the generation of an invoice from a modified Opportunity. One of the required fields on the invoice is a custom field called “Fill Date/Time” which is of the a date datatype.

 

The issue is that the user enters a Fill Date/Time on the opportunity screen in Pacific Time (eg: 9/30/2011 2:44PM), however when the invoice is generated, the Time appears as GMT (eg: 9/30/2011, 21:44:00 GMT).

 

The invoice is generated as a PDF via a Visualforce page – I have copied the relevant code below:

 

<tr>

    <td></td>

        <td width="70%">Fill Date/Time:

               <apex:outputText value="{0,date,MM'/'dd'/'yyyy, HH:mm:ss z}">

                <apex:param value="{!Opportunity.Fill_Date_Time__c}"/>

        </apex:outputText> </td>   

</tr>

<tr>

<td></td>

 

 

I'm new to coding and have referenced the pages below but still don't understand how to fix this. Do I need to save the Opportunity.Fill_Date_Time to some new variable and then format that? Thanks for your help!

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_outputText.htm

Hello,

 

I found a previous post referencing this but cannot seem to get it to work in my org.  I am already using an Extension on this page to reference users information from names in a picklist.  I have tried to put two extensions, such as extensions="ProjectConfirmationEXT,timeZone" but get the following error,  "Error: Unknown constructor 'timeZone.timeZone(ApexPages.StandardController controller)'"

 

Can someone help me figure out what I am doing wrong?

 

VisualForce page

 

<apex:page standardController="Job__c" extensions="ProjectConfirmationEXT" showHeader="false" renderAs="pdf">

<apex:dataTable style="font-family: Calibri, sans-serif;" id="EventTable" value="{!Job__c.Events}" var="e" width="100%" rowClasses="odd,even" styleClass="tableClass" cellpadding="4" border="1">     
        
        <apex:column headerValue="Date">
            <apex:outputField value="{0,date,MM/dd/yyyy}">
                <apex:param value="{!e.StartDateTime}" />
            </apex:outputField>
        </apex:column>
        <apex:column headerValue="Start Time">
            <apex:outputText value="{0,time,HH:MM}">
                <apex:param value="{!e.StartDateTime}" />
            </apex:outputText>
        </apex:column>
        <apex:column headerValue="End Time">
            <apex:outputText value="{0,time,HH:MM}">
                <apex:param value="{!e.EndDateTime}" />
            </apex:outputText>
        </apex:column>
        
    </apex:dataTable>

 

timeZone EXT

 

public class timeZone {
        public String dateTimeValue { get; set; }
        public timeZone() {
            dateTimeValue = System.Now().format('MM/dd/yy HH:mm a', 'PST');//GMT
        }
}

 

 

 

 

 

Hi all,

 

I have a question is it possible to show visualforce page on the page layout when I hit edit button ? My case is I want to show the visualforce page and standar page layout at the same time on page layout in edit mode. Is is possible to do that? Or maybe there is other suggestions for may case would be great.

 

Thanks

 

Regards,

 

Edwin

We've been struggling with getting a zipped static resource to work for weeks now. We got Salesforce Support involved from the beginning, but they've gotten us nowhere. If we can't get a resolution to this issue soon, we might just find a platform that wastes less of our time...

 

Here is the situation - we are trying to upload a portion of the YUI library as a static resource, but no matter what we try, we can't get the files to render in our VisualForce pages. Salesforce Support can get it to work (sometimes), but we can't. The difference seems to be around the MIME Type that is set when the file is uploaded. When we upload the file, it gets set to a MIME Type of 'application/zip', but when SFDC Support uploads the file, it gets set to a MIME Type of 'application/x-zip-compressed' or 'application/octet-stream'. Salesforce can't explain to us exactly why or how these different MIME Types get set. They're looking into why our uploads don't work, but I'm not expecting much from them at this point.

 

To reproduce our steps:

 

Download the file from here after clicking the radio button labeled "Full developer kit":

Steps:
  1. Download "Full developer kit"
  2. Open zip and remov the documentation and examples folders (to reduce size)
  3. Change file name from "yui_3.0.0.zip" to "yui.zip"
  4. Upload as a static resource named "testyui"
  5. In component "header" (where all other JS files are included) add:
    • <apex:includeScript value="{!URLFOR($Resource.testyui, 'yui/build/yui/yui-min.js')}" />
  6. If we refresh the page we get a 404 error for this resource.
 
If anyone has experienced a similar issue, any help you could provide would be greatly appreciated.