You need to sign in to do that
Don't have an account?
bakum
passing ID as parameter overridden by url ID?
Hi, I am trying to make a VF page to replace something I did pretty easily with s-controls.
Basically, I have an object, System_Engineer__c which a related object (1:n) Support_Time__c. The Support_Time__c records have an Approved__c field (checkbox).
What I want to do is display a list of the unapproved support time records on the System_Engineer's detail page, and then provide a link to approve each record. Eventually, I'd like to have checkboxes next to each unapproved record, one Submit button at the bottom, and then the controller updates the APproved__c field for every checked record, but that's getting ahead of myself. Right now, clicking an [ approve ] link should simply update the single record in question. But it doesn't work. It seems to be passing the ID of the SYstem_Engineer himself, instead of the ID of the Support_Time record. I don't know why.
Any help?
Thanks!
-mb
<apex:page controller="MyController" tabStyle="Sales_Engineer__c">
<apex:detail relatedList="false" />
<apex:form >
<apex:pageBlock title="My Unapproved Support Times">
<apex:dataTable id="timesTable" value="{!myUnapprovedTimes}" var="aTime" width="50%" >
<apex:column ><apex:facet name="header"><b>Date</b></apex:facet>{!aTime.Date__c}</apex:column>
<apex:column ><apex:facet name="header"><b>Hours</b></apex:facet>{!aTime.Hours__c}</apex:column>
<apex:column ><apex:facet name="header"><b>Approve All</b></apex:facet>
<apex:commandLink action="{!approveMe}" value="[ approve ]" reRender="timesTable">
<apex:param value="{!aTime.Id}" assignTo="{!myId}"></apex:param>
</apex:commandLink>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:form>
</apex:page>
~~~~~~~~~~~~~~~~
public class MyController {
Id myId;
public void setMyId(Id id)
{
myId = id;
}
public String getMyId() {
return myId;
}
public List<Support_Time__c> getMyUnapprovedTimes()
{
return [SELECT Id, Date__c, Hours__c, Approved__c FROM Support_Time__c
WHERE Sales_Engineer__c = :System.currentPageReference().getParameters().get('id')
AND Approved__c = FALSE
ORDER BY Date__C DESC];
}
public PageReference approveMe() {
Support_Time__c st = [SELECT Id, Name FROM Support_Time__C WHERE Id=:myId];
st.Approved__c = TRUE;
update st;
return null;
}
}
Basically, I have an object, System_Engineer__c which a related object (1:n) Support_Time__c. The Support_Time__c records have an Approved__c field (checkbox).
What I want to do is display a list of the unapproved support time records on the System_Engineer's detail page, and then provide a link to approve each record. Eventually, I'd like to have checkboxes next to each unapproved record, one Submit button at the bottom, and then the controller updates the APproved__c field for every checked record, but that's getting ahead of myself. Right now, clicking an [ approve ] link should simply update the single record in question. But it doesn't work. It seems to be passing the ID of the SYstem_Engineer himself, instead of the ID of the Support_Time record. I don't know why.
Any help?
Thanks!
-mb
<apex:page controller="MyController" tabStyle="Sales_Engineer__c">
<apex:detail relatedList="false" />
<apex:form >
<apex:pageBlock title="My Unapproved Support Times">
<apex:dataTable id="timesTable" value="{!myUnapprovedTimes}" var="aTime" width="50%" >
<apex:column ><apex:facet name="header"><b>Date</b></apex:facet>{!aTime.Date__c}</apex:column>
<apex:column ><apex:facet name="header"><b>Hours</b></apex:facet>{!aTime.Hours__c}</apex:column>
<apex:column ><apex:facet name="header"><b>Approve All</b></apex:facet>
<apex:commandLink action="{!approveMe}" value="[ approve ]" reRender="timesTable">
<apex:param value="{!aTime.Id}" assignTo="{!myId}"></apex:param>
</apex:commandLink>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:form>
</apex:page>
~~~~~~~~~~~~~~~~
public class MyController {
Id myId;
public void setMyId(Id id)
{
myId = id;
}
public String getMyId() {
return myId;
}
public List<Support_Time__c> getMyUnapprovedTimes()
{
return [SELECT Id, Date__c, Hours__c, Approved__c FROM Support_Time__c
WHERE Sales_Engineer__c = :System.currentPageReference().getParameters().get('id')
AND Approved__c = FALSE
ORDER BY Date__C DESC];
}
public PageReference approveMe() {
Support_Time__c st = [SELECT Id, Name FROM Support_Time__C WHERE Id=:myId];
st.Approved__c = TRUE;
update st;
return null;
}
}
you could also avoid this second query if you stored the list in a map with the id as the key.
Message Edited by Ron Hess on 08-07-2008 05:31 PM