You need to sign in to do that
Don't have an account?
TC Admin
VF Page Error: There is no record to save
I have a VF page that gets child records for a custom object master record and displays in an editable grid format.
However once I press "Save" i get the below error:
Error: There is no record to save
I'm guessing this is becasue the button triggers from the master object but the page controller uses the child records however if I switch the controller and page to be a related list the controller no longer works.
Controller:
public class EditAllButtonForTimeSheetController {
public EditAllButtonForTimeSheetController(ApexPages.StandardController controller) {
}
public String TSRecordId {get; set;}
public List<Time_Sheet_Items__c> getTimeSheetRecords()
{
//Sets Time Shet id to variable
TSRecordId = ApexPages.CurrentPage().getparameters().get('id');
// this query needs a where clause, don't leave it unbounded
List<Time_sheet_Items__C> TimeSheetRecords =
[SELECT Id,
Time_Sheet__c,
D_Type__c,
D_Product_manager__c,
D_Project__c,
Day_Monday__c,
Day_Tuesday__c,
Day_Wednesday__c,
Day_Thursday__c,
Day_Friday__c,
Day_Weekend__c
FROM Time_Sheet_Items__c
WHERE Time_sheet__c = :TSRecordId ];
return TimeSheetRecords;
}
}
VF Page:
<apex:page standardController="Time_Sheet__c"
Extensions="EditAllButtonForTimeSheetController">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save"
action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!TimeSheetRecords}"
var="TSi">
<apex:column style="width:5%" value="{!TSi.D_Project__c}"/>
<apex:column style="width:5%" value="{!TSi.D_Type__c}"/>
<apex:column style="width:5%" value="{!TSi.D_Product_Manager__c}"/>
<apex:column style="width:5%" headerValue="Monday">
<apex:inputField value="{!TSi.Day_Monday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Tuesday">
<apex:inputField value="{!TSi.Day_Tuesday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Wednesday">
<apex:inputField value="{!TSi.Day_Wednesday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Thursday">
<apex:inputField value="{!TSi.Day_Thursday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Friday">
<apex:inputField value="{!TSi.Day_Friday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Weekend">
<apex:inputField value="{!TSi.Day_Weekend__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
However once I press "Save" i get the below error:
Error: There is no record to save
I'm guessing this is becasue the button triggers from the master object but the page controller uses the child records however if I switch the controller and page to be a related list the controller no longer works.
Controller:
public class EditAllButtonForTimeSheetController {
public EditAllButtonForTimeSheetController(ApexPages.StandardController controller) {
}
public String TSRecordId {get; set;}
public List<Time_Sheet_Items__c> getTimeSheetRecords()
{
//Sets Time Shet id to variable
TSRecordId = ApexPages.CurrentPage().getparameters().get('id');
// this query needs a where clause, don't leave it unbounded
List<Time_sheet_Items__C> TimeSheetRecords =
[SELECT Id,
Time_Sheet__c,
D_Type__c,
D_Product_manager__c,
D_Project__c,
Day_Monday__c,
Day_Tuesday__c,
Day_Wednesday__c,
Day_Thursday__c,
Day_Friday__c,
Day_Weekend__c
FROM Time_Sheet_Items__c
WHERE Time_sheet__c = :TSRecordId ];
return TimeSheetRecords;
}
}
VF Page:
<apex:page standardController="Time_Sheet__c"
Extensions="EditAllButtonForTimeSheetController">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save"
action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!TimeSheetRecords}"
var="TSi">
<apex:column style="width:5%" value="{!TSi.D_Project__c}"/>
<apex:column style="width:5%" value="{!TSi.D_Type__c}"/>
<apex:column style="width:5%" value="{!TSi.D_Product_Manager__c}"/>
<apex:column style="width:5%" headerValue="Monday">
<apex:inputField value="{!TSi.Day_Monday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Tuesday">
<apex:inputField value="{!TSi.Day_Tuesday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Wednesday">
<apex:inputField value="{!TSi.Day_Wednesday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Thursday">
<apex:inputField value="{!TSi.Day_Thursday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Friday">
<apex:inputField value="{!TSi.Day_Friday__c}"/>
</apex:column>
<apex:column style="width:5%" headerValue="Weekend">
<apex:inputField value="{!TSi.Day_Weekend__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
I would try:
a) Creating StdController on the Child record... first and see what happens
All Answers
I would try:
a) Creating StdController on the Child record... first and see what happens
The ID (blahblahlabh) does not exsist on the controller time_sheet_items__c
In a previous question I asked someone advised me to switch the VF page to the master object Time_sheets__C and then it worked except for the save button.