-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
6Questions
-
11Replies
Adding multiple rows; not working.
Hi -
I have a Mass Create Button that I'm trying to get functionality to work on but it doesn't seem to be going to plan. Can someone assist?
I'm trying to get multiple rows to be created when I click on the "Add Assignment Row" button, but it just refreshes the page and shows a single row again (see button and row below).
This is my current VF Page:
<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddanotherAssignmentController" > <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="Bill Rate"> <apex:inputField value="{!TC.pse__Bill_Rate__c}"/> </apex:column> <apex:column headerValue="Start Date"> <apex:inputField value="{!TC.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date"> <apex:inputField value="{!TC.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="{!save}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
and this is my current Apex Class Page:
public class AddanotherAssignmentController { public AddanotherAssignmentController(ApexPages.StandardSetController controller) { } pse__Assignment__c assignment = new pse__Assignment__c(); public list<pse__Assignment__c> listAssignment{ get; set; } public AddanotherAssignmentController() { listAssignment=new list<pse__Assignment__c>(); listAssignment.add(assignment); } Public void addAssignment() { pse__Assignment__c TC = new pse__Assignment__c(); listAssignment = new List<pse__Assignment__c>(); listAssignment.add(TC); } public PageReference saveAssignment() { for(Integer i=0; i<listAssignment.size(); i++) { insert listAssignment; } return Page.Allassignmentsaved; } }
Any interpretation as to why I'm only getting one row added at a time would be very useful.
Many thanks,
Ethan
- Ethan West
- October 28, 2019
- Like
- 0
Error: Unknown property 'VisualforceArrayList.Name'
Hi,
I've got a requirement for a button that mass creates assignments against the list view.
I've got a controller set but can't seem to get the VF page I have set out to save with the controller active.
Any chance anyone can advise as to what I'm doing wrong & how to resolve?
Error:
Error: Unknown property 'VisualforceArrayList.Name'
Apex:
public class AddmultipleAssignmentController { public pse__Assignment__c del; public List<pse__Assignment__c> TC {get; set;} public List<pse__Assignment__c> delTCList {get; set;} public List<pse__Assignment__c> listAssignment {get; set;} public Integer rowIndex {get; set;} public AddmultipleAssignmentController(ApexPages.StandardSetController controller) { pse__Assignment__c a = new pse__Assignment__c(); listAssignment = new List<pse__Assignment__c>(); listAssignment.add(a); delTCList = new List<pse__Assignment__c>(); TC = new List<pse__Assignment__c>(); } public void addRow(){ pse__Assignment__c a = new pse__Assignment__c(); listAssignment.add(a); } public PageReference save(){ for(pse__Assignment__c s2 : listAssignment){ TC.add(s2); return Page.Allassignmentsaved; } insert TC; listAssignment.clear(); addRow(); return null; } public void deleteRow(){ rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex')); del = listAssignment.remove(rowIndex); delTCList.add(del); } }
VF Page:
<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddmultipleAssignmentController" > <apex:enhancedList type="pse__Assignment__c" height="300" rowsPerPage="10" id="ListViewID"/> <apex:form> <apex:pageBlock title="Assignments" id="pb"> <apex:variable var="rowNumber" value="{!0}"/> <apex:pageblockSection columns="1"> <apex:pageBlockTable title="Assignments" value="{!listAssignment}" var="TC"> <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext"> <apex:outputText value="{0}" style="text-align:center;"> <apex:param value="{!rowNumber+1}"/> </apex:outputText> </apex:column> <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="Bill Rate"> <apex:inputField value="{!TC.pse__Bill_Rate__c}"/> </apex:column> <apex:column headerValue="Start Date"> <apex:inputField value="{!TC.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date"> <apex:inputField value="{!TC.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:column headerValue="Action"> <apex:commandButton value="Delete Row" action="{!deleteRow}" reRender="pb"/> <apex:param name="rowIndex" value="{!rowNumber+1}"/> </apex:column> </apex:pageBlockTable> <apex:commandButton action="{!addRow}" value="Add Assignment" rerender="pb"/> </apex:pageblockSection> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
- Ethan West
- October 28, 2019
- Like
- 0
Error: Unknown property 'pse_Assignment_cStandardController.listAssignment'
I was working off the recommendation of a separate user's piece for a mass create feature that adds additional rows.
I've attempted bastardising their work and adding mine splintered into it, I now have the Apex Code Controller saved as such;
public class AddmultipleAssignmentController { public pse__Assignment__c del; public List<pse__Assignment__c> TC {get; set;} public List<pse__Assignment__c> delTCList {get; set;} public List<pse__Assignment__c> AssignmentList {get; set;} public Integer rowIndex {get; set;} public AddmultipleAssignmentController(ApexPages.StandardSetController controller) { pse__Assignment__c a = new pse__Assignment__c(); AssignmentList = new List<pse__Assignment__c>(); AssignmentList.add(a); delTCList = new List<pse__Assignment__c>(); TC = new List<pse__Assignment__c>(); } public void addRow(){ pse__Assignment__c a = new pse__Assignment__c(); AssignmentList.add(a); } public PageReference save(){ for(pse__Assignment__c s2 : AssignmentList){ TC.add(s2); return Page.Allassignmentsaved; } insert TC; AssignmentList.clear(); addRow(); return null; } public void deleteRow(){ rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex')); del = AssignmentList.remove(rowIndex); delTCList.add(del); } }but when trying to save the referencing VisualForce Code;
<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddmultipleAssignmentController" > <apex:enhancedList type="pse__Assignment__c" height="300" rowsPerPage="10" id="ListViewID"/> <apex:form> <apex:pageBlock title="Assignments" id="pb"> <apex:variable var="rowNumber" value="{!0}"/> <apex:pageblockSection columns="1"> <apex:pageBlockTable title="Assignments" value="{!listAssignment}" var="TC"> <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext"> <apex:outputText value="{0}" style="text-align:center;"> <apex:param value="{!rowNumber+1}"/> </apex:outputText> </apex:column> <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="Bill Rate"> <apex:inputField value="{!TC.pse__Bill_Rate__c}"/> </apex:column> <apex:column headerValue="Start Date"> <apex:inputField value="{!TC.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date"> <apex:inputField value="{!TC.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:column headerValue="Action"> <apex:commandButton value="Delete Row" action="{!deleteRow}" reRender="pb"/> <apex:param name="rowIndex" value="{!rowNumber+1}"/> </apex:column> </apex:pageBlockTable> <apex:commandButton action="{!addRow}" value="Add Assignment" rerender="pb"/> </apex:pageblockSection> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
I get the error;
Error: Unknown property 'pse__Assignment__cStandardController.listAssignment'
I can't see where I have referenced this; could anyone please advise?
Kind regards,
Ethan
- Ethan West
- October 25, 2019
- Like
- 0
list.add Apex Class error.
Hi All,
I have a VisualForce page that should allow me to mass create assigments.
I have a couple rows in my VF page that look like such;
<apex:pageBlockButtons > <apex:commandButton value="Add Assignment Row" action="{!addAssignment}"/> <apex:commandButton value="Save Assignments" action="{!saveAssignment}"/> </apex:pageBlockButtons>When I try to use the "Add Assignment Row" button it comes with the following error.
"Attempt to de-reference a null object
Error is in expression '{!addAssignment}' in component <apex:commandButton> in page mass_create_assignment: Class.AddmultipleAssignmentController.addAssignment: line 17, column 1"
This refers to my extension within my Apex Class;
public class AddmultipleAssignmentController { public AddmultipleAssignmentController(ApexPages.StandardSetController controller) { } 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(assignment); } public PageReference saveAssignment() { for(Integer i=0; i<listAssignment.size(); i++) { insert listAssignment; } return Page.Allassignmentsaved; } }In particular L17;C1 -
listAssignment.add(assignment);which I have tried as -
listAssignment.add(TC);&
listAssignment.add(pse__assignment__c);
(which definitely doesn't work)
Could someone point out what I'm doing wrong within my Apex Class code that's not allowing me to add a row.
Thanks,
Ethan
- Ethan West
- October 24, 2019
- Like
- 0
List Button with VisualForce Content Source
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.
- Ethan West
- October 24, 2019
- Like
- 0
Mass Create Button; Possible?
I already have pre-existing Mass-Edit buttons made via VisualForce which were relatively straight forward and was curious whether the functionality to create a "Mass Create" exists as I can't find much about it online.
Many thanks.
- Ethan West
- October 22, 2019
- Like
- 0
Adding multiple rows; not working.
Hi -
I have a Mass Create Button that I'm trying to get functionality to work on but it doesn't seem to be going to plan. Can someone assist?
I'm trying to get multiple rows to be created when I click on the "Add Assignment Row" button, but it just refreshes the page and shows a single row again (see button and row below).
This is my current VF Page:
<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddanotherAssignmentController" > <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="Bill Rate"> <apex:inputField value="{!TC.pse__Bill_Rate__c}"/> </apex:column> <apex:column headerValue="Start Date"> <apex:inputField value="{!TC.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date"> <apex:inputField value="{!TC.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="{!save}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
and this is my current Apex Class Page:
public class AddanotherAssignmentController { public AddanotherAssignmentController(ApexPages.StandardSetController controller) { } pse__Assignment__c assignment = new pse__Assignment__c(); public list<pse__Assignment__c> listAssignment{ get; set; } public AddanotherAssignmentController() { listAssignment=new list<pse__Assignment__c>(); listAssignment.add(assignment); } Public void addAssignment() { pse__Assignment__c TC = new pse__Assignment__c(); listAssignment = new List<pse__Assignment__c>(); listAssignment.add(TC); } public PageReference saveAssignment() { for(Integer i=0; i<listAssignment.size(); i++) { insert listAssignment; } return Page.Allassignmentsaved; } }
Any interpretation as to why I'm only getting one row added at a time would be very useful.
Many thanks,
Ethan
- Ethan West
- October 28, 2019
- Like
- 0
Error: Unknown property 'VisualforceArrayList.Name'
Hi,
I've got a requirement for a button that mass creates assignments against the list view.
I've got a controller set but can't seem to get the VF page I have set out to save with the controller active.
Any chance anyone can advise as to what I'm doing wrong & how to resolve?
Error:
Error: Unknown property 'VisualforceArrayList.Name'
Apex:
public class AddmultipleAssignmentController { public pse__Assignment__c del; public List<pse__Assignment__c> TC {get; set;} public List<pse__Assignment__c> delTCList {get; set;} public List<pse__Assignment__c> listAssignment {get; set;} public Integer rowIndex {get; set;} public AddmultipleAssignmentController(ApexPages.StandardSetController controller) { pse__Assignment__c a = new pse__Assignment__c(); listAssignment = new List<pse__Assignment__c>(); listAssignment.add(a); delTCList = new List<pse__Assignment__c>(); TC = new List<pse__Assignment__c>(); } public void addRow(){ pse__Assignment__c a = new pse__Assignment__c(); listAssignment.add(a); } public PageReference save(){ for(pse__Assignment__c s2 : listAssignment){ TC.add(s2); return Page.Allassignmentsaved; } insert TC; listAssignment.clear(); addRow(); return null; } public void deleteRow(){ rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex')); del = listAssignment.remove(rowIndex); delTCList.add(del); } }
VF Page:
<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddmultipleAssignmentController" > <apex:enhancedList type="pse__Assignment__c" height="300" rowsPerPage="10" id="ListViewID"/> <apex:form> <apex:pageBlock title="Assignments" id="pb"> <apex:variable var="rowNumber" value="{!0}"/> <apex:pageblockSection columns="1"> <apex:pageBlockTable title="Assignments" value="{!listAssignment}" var="TC"> <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext"> <apex:outputText value="{0}" style="text-align:center;"> <apex:param value="{!rowNumber+1}"/> </apex:outputText> </apex:column> <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="Bill Rate"> <apex:inputField value="{!TC.pse__Bill_Rate__c}"/> </apex:column> <apex:column headerValue="Start Date"> <apex:inputField value="{!TC.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date"> <apex:inputField value="{!TC.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:column headerValue="Action"> <apex:commandButton value="Delete Row" action="{!deleteRow}" reRender="pb"/> <apex:param name="rowIndex" value="{!rowNumber+1}"/> </apex:column> </apex:pageBlockTable> <apex:commandButton action="{!addRow}" value="Add Assignment" rerender="pb"/> </apex:pageblockSection> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
- Ethan West
- October 28, 2019
- Like
- 0
Error: Unknown property 'pse_Assignment_cStandardController.listAssignment'
I was working off the recommendation of a separate user's piece for a mass create feature that adds additional rows.
I've attempted bastardising their work and adding mine splintered into it, I now have the Apex Code Controller saved as such;
public class AddmultipleAssignmentController { public pse__Assignment__c del; public List<pse__Assignment__c> TC {get; set;} public List<pse__Assignment__c> delTCList {get; set;} public List<pse__Assignment__c> AssignmentList {get; set;} public Integer rowIndex {get; set;} public AddmultipleAssignmentController(ApexPages.StandardSetController controller) { pse__Assignment__c a = new pse__Assignment__c(); AssignmentList = new List<pse__Assignment__c>(); AssignmentList.add(a); delTCList = new List<pse__Assignment__c>(); TC = new List<pse__Assignment__c>(); } public void addRow(){ pse__Assignment__c a = new pse__Assignment__c(); AssignmentList.add(a); } public PageReference save(){ for(pse__Assignment__c s2 : AssignmentList){ TC.add(s2); return Page.Allassignmentsaved; } insert TC; AssignmentList.clear(); addRow(); return null; } public void deleteRow(){ rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex')); del = AssignmentList.remove(rowIndex); delTCList.add(del); } }but when trying to save the referencing VisualForce Code;
<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddmultipleAssignmentController" > <apex:enhancedList type="pse__Assignment__c" height="300" rowsPerPage="10" id="ListViewID"/> <apex:form> <apex:pageBlock title="Assignments" id="pb"> <apex:variable var="rowNumber" value="{!0}"/> <apex:pageblockSection columns="1"> <apex:pageBlockTable title="Assignments" value="{!listAssignment}" var="TC"> <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext"> <apex:outputText value="{0}" style="text-align:center;"> <apex:param value="{!rowNumber+1}"/> </apex:outputText> </apex:column> <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="Bill Rate"> <apex:inputField value="{!TC.pse__Bill_Rate__c}"/> </apex:column> <apex:column headerValue="Start Date"> <apex:inputField value="{!TC.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date"> <apex:inputField value="{!TC.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:column headerValue="Action"> <apex:commandButton value="Delete Row" action="{!deleteRow}" reRender="pb"/> <apex:param name="rowIndex" value="{!rowNumber+1}"/> </apex:column> </apex:pageBlockTable> <apex:commandButton action="{!addRow}" value="Add Assignment" rerender="pb"/> </apex:pageblockSection> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
I get the error;
Error: Unknown property 'pse__Assignment__cStandardController.listAssignment'
I can't see where I have referenced this; could anyone please advise?
Kind regards,
Ethan
- Ethan West
- October 25, 2019
- Like
- 0
list.add Apex Class error.
Hi All,
I have a VisualForce page that should allow me to mass create assigments.
I have a couple rows in my VF page that look like such;
<apex:pageBlockButtons > <apex:commandButton value="Add Assignment Row" action="{!addAssignment}"/> <apex:commandButton value="Save Assignments" action="{!saveAssignment}"/> </apex:pageBlockButtons>When I try to use the "Add Assignment Row" button it comes with the following error.
"Attempt to de-reference a null object
Error is in expression '{!addAssignment}' in component <apex:commandButton> in page mass_create_assignment: Class.AddmultipleAssignmentController.addAssignment: line 17, column 1"
This refers to my extension within my Apex Class;
public class AddmultipleAssignmentController { public AddmultipleAssignmentController(ApexPages.StandardSetController controller) { } 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(assignment); } public PageReference saveAssignment() { for(Integer i=0; i<listAssignment.size(); i++) { insert listAssignment; } return Page.Allassignmentsaved; } }In particular L17;C1 -
listAssignment.add(assignment);which I have tried as -
listAssignment.add(TC);&
listAssignment.add(pse__assignment__c);
(which definitely doesn't work)
Could someone point out what I'm doing wrong within my Apex Class code that's not allowing me to add a row.
Thanks,
Ethan
- Ethan West
- October 24, 2019
- Like
- 0
List Button with VisualForce Content Source
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.
- Ethan West
- October 24, 2019
- Like
- 0
Mass Create Button; Possible?
I already have pre-existing Mass-Edit buttons made via VisualForce which were relatively straight forward and was curious whether the functionality to create a "Mass Create" exists as I can't find much about it online.
Many thanks.
- Ethan West
- October 22, 2019
- Like
- 0