You need to sign in to do that
Don't have an account?
TC Admin
Apex coding to pass VisualForce Page parametrs
Hi all,
I'm trying to write a related list button on a master record that opens a table that you can edit certain fields of the masters child records.
My visual force page works but gets ALL child records in the system not just those relating to the master record I am on.
My Apex coding is:
public class EditAllButtonForTimeSheetController
{
//This will store the Id from the URL i.e., the Id of the Record that belongs to the Master Object
public String TSRecordId {get; set;}
public List<Time_Sheet_Items__c> TSiRecords {get; set;}
public Time_Sheet__c TSRecord {get; set;}
//Constructor. This would build everything for our VF Page.
public EditAllButtonForTimeSheetController()
{
TSRecordId = ApexPages.CurrentPage().getparameters().get('id');
//Make sure we have the Id in the URL
if(!String.isBlank(TSRecordId)){
//Fetch the Time Sheet Record Details
TSRecord =
[SELECT ID,Name,Time_Sheet_Week_Ending__c FROM Time_Sheet__c WHERE Id = :TSRecordId ];
//Fetch all the Time_Sheet_Items Records with respect to the Time_sheet Record.
//Note: Child_To_Parent_Lookup__c is Lookup/M-D field on my Child SObject to the Parent – Master
TSiRecords =
[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_ID__c = :TSRecordId ];
}
}
}
VF PAGE
<apex:page standardController="Time_Sheet_Items__c"
Extensions="EditAllButtonForTimeSheetController">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save"
action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Time_Sheet_Items__c}"
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>
Any help would be great.
I'm trying to write a related list button on a master record that opens a table that you can edit certain fields of the masters child records.
My visual force page works but gets ALL child records in the system not just those relating to the master record I am on.
My Apex coding is:
public class EditAllButtonForTimeSheetController
{
//This will store the Id from the URL i.e., the Id of the Record that belongs to the Master Object
public String TSRecordId {get; set;}
public List<Time_Sheet_Items__c> TSiRecords {get; set;}
public Time_Sheet__c TSRecord {get; set;}
//Constructor. This would build everything for our VF Page.
public EditAllButtonForTimeSheetController()
{
TSRecordId = ApexPages.CurrentPage().getparameters().get('id');
//Make sure we have the Id in the URL
if(!String.isBlank(TSRecordId)){
//Fetch the Time Sheet Record Details
TSRecord =
[SELECT ID,Name,Time_Sheet_Week_Ending__c FROM Time_Sheet__c WHERE Id = :TSRecordId ];
//Fetch all the Time_Sheet_Items Records with respect to the Time_sheet Record.
//Note: Child_To_Parent_Lookup__c is Lookup/M-D field on my Child SObject to the Parent – Master
TSiRecords =
[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_ID__c = :TSRecordId ];
}
}
}
VF PAGE
<apex:page standardController="Time_Sheet_Items__c"
Extensions="EditAllButtonForTimeSheetController">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save"
action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Time_Sheet_Items__c}"
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>
Any help would be great.
Id value a0R7E0000003ckd is not valid for the Time_Sheet_Items__c standard controller
The ID value is for the master record. It like its trying to use my master record ID as the Ids for the child records tables but I do not know why.
Did you get this error after the change I suggested? Since, you are using "Time_Sheet_Items__c" as standard controller, value in "id" parameter(in URL) should be a valid recordId of "Time_Sheet_Items__c". Error is suggesting the same.
If you are passing child record id then use child object as standard controller.
I was gettignt eh error before your change. However if I remove the extention the visual force page runs but with ALL child records on the system not just the ones that are attached to the master. So I know the page works its is the apex that does not.