You need to sign in to do that
Don't have an account?
satakshi
Can not see visualforce page in the content source drop down
Hello,
I am not able to create custom button as in a cotent source drop down list there is no visualforce page to select.
My code is
Controller:
public with sharing class MyCompController
{
Map<Integer, Account> AccountIdList = new Map<Integer, Account>();
public MyCompController() {
Integer i = 0;
for (Account a : [SELECT Id, Name FROM Account]) {
AccountIdList.put(i, a);
i++;
}
}
public Map<Integer, Account> getAccountIdList() {
return AccountIdList;
}
}
VF Page:
<apex:page controller="MyCompController"> <apex:form > <apex:repeat value="{!AccountIdList}" var="accNum"> <apex:outputText value="({!AccountIdList[accNum]}, {!AccountIdList[accNum].Name})" /><br/> </apex:repeat> </apex:form> </apex:page>
I am not able to create custom button as in a cotent source drop down list there is no visualforce page to select.
My code is
Controller:
public with sharing class MyCompController
{
Map<Integer, Account> AccountIdList = new Map<Integer, Account>();
public MyCompController() {
Integer i = 0;
for (Account a : [SELECT Id, Name FROM Account]) {
AccountIdList.put(i, a);
i++;
}
}
public Map<Integer, Account> getAccountIdList() {
return AccountIdList;
}
}
VF Page:
<apex:page controller="MyCompController"> <apex:form > <apex:repeat value="{!AccountIdList}" var="accNum"> <apex:outputText value="({!AccountIdList[accNum]}, {!AccountIdList[accNum].Name})" /><br/> </apex:repeat> </apex:form> </apex:page>
use standardController="Planned_visit__c" instead of standardController="account" with my Ist code.
Thanks
Ankur Saini
http://mirketa.com
All Answers
If you want to create a custom button on Account object or any other custom object, you must specify the standard controller as mention below
try this:--
public with sharing class MyCompController
{
public MyCompController(ApexPages.StandardController controller) {
Integer i = 0;
for (Account a : [SELECT Id, Name FROM Account]) {
AccountIdList.put(i, a);
i++;
}
}
Map<Integer, Account> AccountIdList = new Map<Integer, Account>();
public Map<Integer, Account> getAccountIdList() {
return AccountIdList;
}
}
<apex:page standardController="account" extensions="MyCompController"> <apex:form > <apex:repeat value="{!AccountIdList}" var="accNum"> <apex:outputText value="({!AccountIdList[accNum]}, {!AccountIdList[accNum].Name})" /><br/> </apex:repeat> </apex:form> </apex:page>
I am getting this error after trying your code
Loop variable must be an SObject or list of Account
Thanks,
Satakshi
Can you please tell on which object you are trying to create the custom button.
With below code am able to save page and class both without any error.
Class:
public with sharing class MyCompController{
public MyCompController(ApexPages.StandardController controller) {
Integer i = 0;
for (Account a : [SELECT Id, Name FROM Account]) {
AccountIdList.put(i, a);
i++;
}
}
Map<Integer, Account> AccountIdList = new Map<Integer, Account>();
public Map<Integer, Account> getAccountIdList() {
return AccountIdList;
}
}
Page:
<apex:page standardController="account" extensions="MyCompController">
<apex:form >
<apex:repeat value="{!AccountIdList}" var="accNum">
<apex:outputText value="({!AccountIdList[accNum]}, {!AccountIdList[accNum].Name})" /><br/>
</apex:repeat>
</apex:form>
</apex:page>
I repeat, If you want to create a custom button on Account object
My Ist Code is running without any error for Detail Page Button of Account
My 2nd Code is also running without any error for List View Button of Account
2nd Code:--
public with sharing class MyCompController
{
public MyCompController(ApexPages.StandardSetController controller) {
Integer i = 0;
for (Account a : [SELECT Id, Name FROM Account]) {
AccountIdList.put(i, a);
i++;
}
}
Map<Integer, Account> AccountIdList = new Map<Integer, Account>();
public Map<Integer, Account> getAccountIdList() {
return AccountIdList;
}
}
<apex:page standardController="account" extensions="MyCompController" recordSetVar="acc">
<apex:form >
<apex:repeat value="{!AccountIdList}" var="accNum">
<apex:outputText value="({!AccountIdList[accNum]}, {!AccountIdList[accNum].Name})" /><br/>
</apex:repeat>
</apex:form>
</apex:page>
Thanks
Ankur Saini
use standardController="Planned_visit__c" instead of standardController="account" with my Ist code.
Thanks
Ankur Saini
http://mirketa.com
Thanks For the help
Regards,
Satakshi