You need to sign in to do that
Don't have an account?
Jeanne Jobes 1
Visualforce page using a custom controller is not available when creating a new detail page button
public class StockListController {
public List<Stock_Item__c> getStockItems() {
List<Stock_Item__c> results = Database.query(
'SELECT ID, Item_Name__c, Item_Stock_is_Low__c, Minimum_Stock_Level__c, Stock_on_Hand__c ' +
'FROM Stock_Item__c ' +
'WHERE Item_Stock_is_Low__c = true'
);
return results;
}
}
<apex:page lightningStyleSheets="true" Controller="StockListController">
<apex:form>
<apex:pageBlock title="Low Stock Items" id="stock_item_list">
<!-- Stock Item List goes here -->
<apex:pageBlockTable value="{! StockItems }" var="si">
<apex:column value="{! si.ID }"/>
<apex:column value="{! si.Item_Name__c }"/>
<apex:column value="{! si.Item_Stock_is_Low__c }"/>
<apex:column value="{! si.Minimum_Stock_Level__c }"/>
<apex:column value="{! si.Stock_on_Hand__c }"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public List<Stock_Item__c> getStockItems() {
List<Stock_Item__c> results = Database.query(
'SELECT ID, Item_Name__c, Item_Stock_is_Low__c, Minimum_Stock_Level__c, Stock_on_Hand__c ' +
'FROM Stock_Item__c ' +
'WHERE Item_Stock_is_Low__c = true'
);
return results;
}
}
<apex:page lightningStyleSheets="true" Controller="StockListController">
<apex:form>
<apex:pageBlock title="Low Stock Items" id="stock_item_list">
<!-- Stock Item List goes here -->
<apex:pageBlockTable value="{! StockItems }" var="si">
<apex:column value="{! si.ID }"/>
<apex:column value="{! si.Item_Name__c }"/>
<apex:column value="{! si.Item_Stock_is_Low__c }"/>
<apex:column value="{! si.Minimum_Stock_Level__c }"/>
<apex:column value="{! si.Stock_on_Hand__c }"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Example imagine I want to add a custom VF page on Account then below is how my VF page should look like.
Hope this helps!
Prady01