function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ethan WestEthan West 

List Button with VisualForce Content Source

I'm currently making a VisualForce Page & Apex Class that allows for a mass create of assignments from the List View on the object pse__Assignment__c.

I believe that the VF and Apex code both work, however, I'm not sure what to add to either to allow the VisualForce page to be picked up as a Content Source when creating the Button.

I'm under the impression it could be that I change the controller to a standardController of pse__Assignment__c and change the current Controller to an extension instead so that it still works off of both the Object and Apex Class, but I'm not really sure how that'd look.

Here's what I have so far;
Visual Force Main:
<apex:page Controller="AddmultipleAssignmentController">
<apex:enhancedList type="pse__Assignment__c" height="300" rowsPerPage="10" id="ListViewID"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!listAssignment}" var="TC">
                <apex:column headerValue="Assignment Name">
                    <apex:inputField value="{!TC.Name}"/>
                </apex:column>
                <apex:column headerValue="Resource">
                    <apex:inputField value="{!TC.pse__Resource__c}"/>
                </apex:column>
                <apex:column headerValue="Project">
                    <apex:inputField value="{!TC.pse__Project__c}"/>
                </apex:column>
                <apex:column headerValue="Candidate">
                    <apex:inputField value="{!TC.Candidate__c}"/>
                </apex:column>
                <apex:column headerValue="Start Date">
                    <apex:inputField value="{!TC.pse__Start_Date__c}"/>
                </apex:column>
                <apex:column headerValue="End Date">
                    <apex:inputField value="{!TC.pse__End_Date__c}"/>
                </apex:column>
                <apex:column headerValue="Monday Hours">
                    <apex:inputField value="{!TC.Monday_Hours__c}"/>
                </apex:column>
                <apex:column headerValue="Tuesday Hours">
                    <apex:inputField value="{!TC.Tuesday_Hours__c}"/>
                </apex:column>
                <apex:column headerValue="Wednesday Hours">
                    <apex:inputField value="{!TC.Wednesday_Hours__c}"/>
                </apex:column>
                <apex:column headerValue="Thursday Hours">
                    <apex:inputField value="{!TC.Thursday_Hours__c}"/>
                </apex:column>
                <apex:column headerValue="Friday Hours">
                    <apex:inputField value="{!TC.Friday_Hours__c}"/>
                </apex:column>                       
                <apex:column headerValue="Saturday Hours">
                    <apex:inputField value="{!TC.Saturday_Hours__c}"/>
                </apex:column>                             
                <apex:column headerValue="Sunday Hours">
                    <apex:inputField value="{!TC.Sunday_Hours__c}"/>
                </apex:column>
            </apex:pageBlockTable>
                <apex:pageBlockButtons >
                    <apex:commandButton value="Add Assignment Row" action="{!addAssignment}"/>
                    <apex:commandButton value="Save Assignments" action="{!saveAssignment}"/>
                </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Apex Class:
public class AddmultipleAssignmentController {
    pse__Assignment__c assignment = new pse__Assignment__c();
    public list<pse__Assignment__c> listAssignment{ get; set; }
    
    public AddmultipleAssignmentController() {
        listAssignment=new list<pse__Assignment__c>();
        listAssignment.add(assignment);
    }
    
    Public void addAssignment() {
        pse__Assignment__c TC = new pse__Assignment__c();
        listAssignment.add(TC);
    }
    public PageReference saveAssignment() {
        for(Integer i=0; i<listAssignment.size(); i++) {
            insert listAssignment;
        }
        return Page.Allassignmentsaved;
    }
}
Return VisualForce "Saved" Page:
<apex:page sidebar="false" showHeader="true">
<center><h3>Your assignments have been successfully saved.
</h3></center>
</apex:page>
If anyone can help point out what I'd need add to either the VF Page or Apex Class it'd be appreciated.

 
Best Answer chosen by Ethan West
Ethan WestEthan West

Just to clean this up I resolved this.
 

If anyone else is in the same spot and needs the reference for a Custom Object with a secondary Controller/Extension it's as so;

VF:

<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddmultipleAssignmentController" >
<apex:enhancedList type="pse__Assignment__c" height="300" rowsPerPage="10" id="ListViewID"/>

Apex:
 
public class AddmultipleAssignmentController {

    public AddmultipleAssignmentController(ApexPages.StandardSetController controller) {

    }