You need to sign in to do that
Don't have an account?
sawaji varun
How to create custom task and added to activities in account
I am able to create the task, If I click the custom button that task should be added to activities in account. How to do it. Please any one help me on this.The Code is given below
VF Page:
<apex:page standardController="Task" extensions="CBD_SendSMS" sidebar="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:inputfield value="{!tsk.Mobile_Number__c}"/>
<apex:inputTextarea value="{!tsk.SMS_Description__c}"/>
<!--<apex:inputField value="{!tsk.Lead_Lookup__c}"/>
<apex:inputField value="{!tsk.Account_Lookup__c}"/>
<apex:inputField value="{!tsk.Opportunity_Lookup__c}"/>-->
</apex:pageBlockSection>
<apex:commandButton value="Send SMS" action="{!sendSMS}" style="margin-left:600px;width=50px;height=30px" reRender="">
<apex:param id="someId" name="accountID" value="{$account.id}"/>
</apex:commandButton>
<apex:outputText value="{!Account.Id}"></apex:outputText>
</apex:pageBlock>
</apex:form>
</apex:page>
____________________________
public with sharing class CBD_SendSMS {
public Task tsk{
get {
if (tsk == null)
tsk = new Task();
return tsk;
}
set;
}
// public Account acc{ get;set;}
public PageReference sendSMS() {
// Integer fPhone=tsk.Mobile_Number__c;
// if (fphone.length() != 10) {
// tsk.addError('Error1');
// }
Id id1= System.currentPageReference().getParameters().get('accountID');
// System.debug('ID Dispalys' +Id);
System.debug('ID Dispalys' +id1);
tsk.WhatId = id1;
// tsk.RecordtypeId = '012p00000004O5k';
//tsk.WhoId=userInfo.getUserId();
insert tsk;
pageReference pageref= new pageReference('/' + tsk.Id);
Task tsk = new Task();
return pageref;
}
public CBD_SendSMS(ApexPages.StandardController controller)
{
this.tsk = (Account)Controller.getRecord();
}
}
VF Page:
<apex:page standardController="Task" extensions="CBD_SendSMS" sidebar="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:inputfield value="{!tsk.Mobile_Number__c}"/>
<apex:inputTextarea value="{!tsk.SMS_Description__c}"/>
<!--<apex:inputField value="{!tsk.Lead_Lookup__c}"/>
<apex:inputField value="{!tsk.Account_Lookup__c}"/>
<apex:inputField value="{!tsk.Opportunity_Lookup__c}"/>-->
</apex:pageBlockSection>
<apex:commandButton value="Send SMS" action="{!sendSMS}" style="margin-left:600px;width=50px;height=30px" reRender="">
<apex:param id="someId" name="accountID" value="{$account.id}"/>
</apex:commandButton>
<apex:outputText value="{!Account.Id}"></apex:outputText>
</apex:pageBlock>
</apex:form>
</apex:page>
____________________________
public with sharing class CBD_SendSMS {
public Task tsk{
get {
if (tsk == null)
tsk = new Task();
return tsk;
}
set;
}
// public Account acc{ get;set;}
public PageReference sendSMS() {
// Integer fPhone=tsk.Mobile_Number__c;
// if (fphone.length() != 10) {
// tsk.addError('Error1');
// }
Id id1= System.currentPageReference().getParameters().get('accountID');
// System.debug('ID Dispalys' +Id);
System.debug('ID Dispalys' +id1);
tsk.WhatId = id1;
// tsk.RecordtypeId = '012p00000004O5k';
//tsk.WhoId=userInfo.getUserId();
insert tsk;
pageReference pageref= new pageReference('/' + tsk.Id);
Task tsk = new Task();
return pageref;
}
public CBD_SendSMS(ApexPages.StandardController controller)
{
this.tsk = (Account)Controller.getRecord();
}
}