I have a Visual Force page that I created that contains a dynamic pick list field I want to add to a page layout. The VF page uses a standard controller for "Account" and has an extension. I am having an issue with the dynamic pick list field displaying on the Account page when I add it to the page layout.
VF Page:
<apex:page standardController="Account" extensions="Account_QuoteTemplatesExtension" showHeader="false" sidebar="false">
<apex:detail />
<apex:form >
<apex:PageBlock mode="edit">
<apex:PageBlockSection title="Quote Template Selection" columns="1">
<apex:PageBlockSectionItem >
<!-- Label for picklist -->
<apex:outputLabel value="Quote Template" for="quoteTemplates" />
<!-- Dynamic picklist of values (quote templates) -->
<apex:selectList value="{!selectedTemplate}" size="1" id="quoteTemplates">
<apex:selectOptions value="{!TemplateOptions}" />
</apex:selectList>
</apex:PageBlockSectionItem>
</apex:PageBlockSection>
</apex:PageBlock>
</apex:form>
</apex:page>
Apex Class Controller:
global with sharing class Account_QuoteTemplatesExtension {
private final ApexPages.StandardController controller;
private final Account record;
private final Id recordId;
public String selectedTemplate {get; set;}
public Account_QuoteTemplatesExtension (ApexPages.StandardController stdController) {
this.controller = stdController;
this.recordId = this.controller.getId();
this.record = [SELECT id, name FROM Account WHERE Id = :this.recordId LIMIT 1];
}
// Returns list of quote template options
public List<SelectOption> getTemplateOptions() {
// Initiate option list
List<SelectOption> tempOptions = new List<SelectOption>();
// Get all quote templates from metadata
List<Quote_Template__mdt> quoteTemplates = [SELECT MasterLabel, Template_Id__c FROM Quote_Template__mdt];
// Add all options to select option list
for (Quote_Template__mdt temp : quoteTemplates) {
tempOptions.add(new SelectOption(temp.Template_ID__c,temp.MasterLabel));
}
return tempOptions;
}
}
I have added the VF page in a section called "Quote Template"
But the section renders blank on the Account record page
The VF page renders fine in the preview, but will not show up embedded on the page layout.
Is this an issue with my controller?
<apex:detail />
...It doesn't make any sense to nest like that.<apex:outputText value="Hello World" />
or some such. If it renders, add tags back in incrementally until it breaks. Also attributes likemode="edit"
could be the cause. If that pared down page still doesn't render, something else is up.<apex:page standardController="Account"> <p> Hello World! </p> </apex:page>
but the page still renders blank on the page layout.