I've been struggling for a while this one and am hoping someone can help. I need to create a Log a Call list button that I can display on Account Activity History Related List. Goal of this button is to create a new record and pre-populate the Status (Completed), Priority (Normal), What Id (Account.Id), Due Date (today), Type (Call), and Subject (Call) fields. Here is the apex and vf page (incomplete but does not generate expected results either way). Any help would be greatly appreciated:
public with sharing class LogACallListButton1 {
public Task task {get; set;}
public LogACallListButton1(ApexPages.StandardController controller) {
this.task = (Task)controller.getRecord();
this.task.whatId = ApexPages.currentPage().getParameters().get('what_id');
this.task.subject = 'Call';
this.task.type = 'Call';
this.task.status = 'Completed';
this.task.priority = 'Normal';
this.task.activitydate = Date.today();
}
}
<apex:page standardController="Task" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Subject</apex:outputLabel>
<apex:inputField id="Subject" value="{!task.Subject}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Comments</apex:outputLabel>
<apex:inputField id="Description" value="{!task.Description}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton id="Save" action="{!Save}" value="Save"/>
<apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>