function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lee.ax1423Lee.ax1423 

Return Task page which is associated with contact

Hi can any one help me on this problem.

In below i have created a task in a specific contact.while i am click the send button in visualforce page the following task will be created and goes to particular contact page whic id we have passed.but i dont want to go my contact page.I want to go my task page which i have previously created in the following code.

here be my sample code.

 

private final Contact contact;

public Task smsTask;

public SendSMSHttpContact(ApexPages.StandardController controller) {
this.contact = (Contact)controller.getRecord();
}

 

public PageReference SendSMS() {

 

smsTask = new Task (Type='SMS',
WhoID = contact.id,
Status = 'Completed',
ActivityDate = System.today(),
Description = msg.replace('%20',' '),
Subject = 'SMS Sent'
);
try {
insert smsTask;
} catch (System.Dmlexception e) {
System.debug('Error: Unable to insert task: ' + e);
}
return new ApexPages.StandardController(contact).view();/*here i am returning to contact page,I want to go task page which i have created*/

}

 

Help??????????

Best Answer chosen by Admin (Salesforce Developers) 
pujapuja

return new PageReferecnce('/'+smsTask.Id');