You need to sign in to do that
Don't have an account?
jeremy_w
how to add standard button (for another object) to a page & data order of pageBlockTable
I've overridden the standard case view with a visualforce page.
I've got a list of tasks in that page that relate to the case.
I'd like to add a standard button to add a new task (just like on the normal "open activities" detail page).
What's the best way to do this?
Also how can I re-order the data shown in a pageBlockTable (ordered by one of the displayed columns in this case)?
Code below:
I've got a list of tasks in that page that relate to the case.
I'd like to add a standard button to add a new task (just like on the normal "open activities" detail page).
What's the best way to do this?
Also how can I re-order the data shown in a pageBlockTable (ordered by one of the displayed columns in this case)?
Code below:
Code:
<apex:page standardController="Case" showHeader="true" sidebar="true" tabStyle="Case"> <style> .activeTab {background-color:#ef2b2d;color:white;background-image:none;} .inactiveTab {background-color:lightgrey;color:black;background-image:none;} </style> <apex:tabPanel switchType="client" selectedTab="tabdetails" id="CaseTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Details" name="CaseDetails" id="tabdetails"> <apex:detail relatedList="false" title="true"></apex:detail> <apex:pageBlock title="Tasks"> <apex:pageblockTable value="{!Case.Tasks}" var="s" columns="3"> <apex:column width="100"> <apex:outputField value="{!s.DateForTimeRecording__c}" /> </apex:column> <apex:column width="120">{!s.Owner.Name}</apex:column> <apex:column >{!s.Subject}</apex:column> <apex:column breakBefore="true"> </apex:column> <apex:column colspan="2">{!s.Description} </apex:column> </apex:pageblockTable> </apex:pageBlock> </apex:tab> <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct"> <apex:relatedList list="OpenActivities" pageSize="20"></apex:relatedList> </apex:tab> </apex:tabPanel> </apex:page>
I'm not a Salesforce expert, just another developer, but these are the options i'm aware of:
Task Button:
- The most rough and ready way to do this is by observing the existing behavior and trying to mimic it. ie see what shows up in the query string parameters when you click on an existing new task button.
- The probably better advised way to go is to either create a method that creates your task (see page 221 in the APEX rdeveloper's guide) if you don't need additional user input, or have the button call a method that returns a PageReference and redirect to a standard task creation form or your own wizard.
Re-ordering Record set1. I've found the existing "new" URL for a task and copied that. It works fine. I may do the APEX replacement at some point but more likely replace the new task page with a visualforce page. Link code is:
2. The ordering of items in the pageBlockTable:
- what I was trying to do was just a simple re-order of the data using the built in ability to specify a collection in the tag:
rather than having to write an APEX class to just get the data and sort. But it looks like that's the only way?
3. A new problem to do with parameters now, I've got another button to create an email and I'm passing parameters to this (it's the same page as the earlier code):
However, I get an error when this button is clicked (seen in a new page):
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: ContactId
I've tried "case.Contact.Id" and the error is the same (but field shown is "Contact").
According to the documentation, this should be fine as the controller is "Case" and to get to the vars using lowercase object name. Maybe the case.ContactId is not being interpreted until the next page and then it's not valid?
Any ideas?
Jeremy
But I had to put the span around the text to make it look like a standard button.
I'd be interested to know what the recommended way to do what I've done is, as I think the commandButton problem is just that it's submitting to the page controller and then doesn't process the parameters as I expected.
Maybe urlfor is supposed to help in somehow?
For example,
Message Edited by ES on 06-17-2008 09:25 AM
I'm interested to know how bugs are dealt with: do they get fixed mid release or do they all get batched up and added to the next release?
As far as I can tell the {!urlfor($Action.Activity.NewTask)} functionality is not usable, most likely because it is not document well enough.
It works, but it is not clear on how the parameters should be passed. For 3 years I have been using the workaround and salesforce seems to have just changed the urls so now my url's are broken.
Can't we just get the proper solution working correctly? Has anyone got an answer?
I would need to pass the id of the parent record, and the recordtype of the task I want to create, and the returl.