You need to sign in to do that
Don't have an account?
custom VisualForce page for task
I would like to create a custom visualforce page for creating a new task. Scenario: user clicks a button on the Activities related list on the parent object. That button launches a VF force page with both standard fields and custom fields for the Task. User populates those fields, then clicks Save.
I've tried all sorts of things hobbled together from research online, but so far, no luck.
(I'm a newbie at VF and apex)
Here's my current VF Page code:
<apex:page standardController="Task" extensions="extension_task">
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!save}" />
</apex:pageblockButtons>
<apex:pageBlockSection title="Quick Edits" columns="1">
<apex:inputField value="{!Task.Whatid}"/>
<apex:inputField value="{!Task.Subject}"/>
<apex:inputField value="{!Task.Representative__c}"/>
<apex:inputField value="{!Task.Category__c}"/>
<apex:inputField value="{!Task.Comments__c}" style="width:400px; height:200px"/>
<apex:inputField value="{!Task.Perceived_Call_Value__c}"/>
<apex:inputField value="{!Task.Referred_To__c}"/>
<apex:inputField value="{!Task.Interaction__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Here's the apex class extension:
public class extension_task{
Task task = new Task();
public extension_task(ApexPages.StandardController controller) {
this.task = (Task)controller.getRecord();
}
}
**************************
I think a problem is that Task cannot be used as a StandardController. I tried setting the StandardController="ACA_Member__c", but that gives me an error (Error: Unknown property 'ACA_Member__cStandardController.Task'). It seems I should be able to use my custom object with standardController based on this page (http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_std_associate.htm).
Thanks any advance for any help!
I've tried all sorts of things hobbled together from research online, but so far, no luck.
(I'm a newbie at VF and apex)
Here's my current VF Page code:
<apex:page standardController="Task" extensions="extension_task">
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!save}" />
</apex:pageblockButtons>
<apex:pageBlockSection title="Quick Edits" columns="1">
<apex:inputField value="{!Task.Whatid}"/>
<apex:inputField value="{!Task.Subject}"/>
<apex:inputField value="{!Task.Representative__c}"/>
<apex:inputField value="{!Task.Category__c}"/>
<apex:inputField value="{!Task.Comments__c}" style="width:400px; height:200px"/>
<apex:inputField value="{!Task.Perceived_Call_Value__c}"/>
<apex:inputField value="{!Task.Referred_To__c}"/>
<apex:inputField value="{!Task.Interaction__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Here's the apex class extension:
public class extension_task{
Task task = new Task();
public extension_task(ApexPages.StandardController controller) {
this.task = (Task)controller.getRecord();
}
}
**************************
I think a problem is that Task cannot be used as a StandardController. I tried setting the StandardController="ACA_Member__c", but that gives me an error (Error: Unknown property 'ACA_Member__cStandardController.Task'). It seems I should be able to use my custom object with standardController based on this page (http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_std_associate.htm).
Thanks any advance for any help!
https://www.salesforce.com/apex/VFPage?subject=test
Then in your apex extension right under where you did the controller.getrecord() you could do
task.subject = System.currentPageReference().getParameters().get('subject');
Here's another example from the dev boards: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000997LIAQ
All Answers
1.) Sounds like you could use standard page layouts to accomplish this...you might not even need VF/Apex.
2.) Based on requirement (quick create of a task) and the code you've provided...looks like you dont even need the extension and Apex class. The standard controller can handle everything by itself. So you dont need to the apex class and you can remove the extension attribute from the page on line 1 of the VF page. So just do: <apex:page standardController="Task">
2. I've tried to just use StandardController="Task". What happends then is strange. It will appear to save the task record and shows me the detail record of the items I just entered (see the first screen shot below). The task has the correct Related To person entered, but when I click on the link of that Related To person, the task does not appear in the activity history. It is like it is not being associated with the Related To item despite the detail record showing it is.
That's why I thought something must be wrong with the way I was using the StandardController.
The bad news is that the fields on my VF task page are not default populating via my URL hack to the VF page as they were to a the standard task page.
After doing a lot of research, it seems that I can't pass parameters via a URL to a VisualForce page using the same URL Hack method. Does anyone have ideas on how I can pre-populated some of the fields on my VF page for Task? My users click an "Engaged" button on the task related list, then are taken to the VF page. I want that VF page to pre-populate some fields. Ideas?
https://www.salesforce.com/apex/VFPage?subject=test
Then in your apex extension right under where you did the controller.getrecord() you could do
task.subject = System.currentPageReference().getParameters().get('subject');
Here's another example from the dev boards: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000997LIAQ
I new to SF Coding, and i got the same issues in my work, users need few comments boxs to be larger, so my manager suggested me to create a new custom VF page for NEW TASK and NEW EVENT, but i dont know how to wtire a code for it. Could you please assest me on how can i do it ? Any suggestions is appriciated. Thanks, Nagendra