You need to sign in to do that
Don't have an account?
Srini
Task Email Notification
Hi All,
Email notification when delegated task is complete.:
For the above requirement i have written a one trigger on Task object.That trigger working as expected.But here my problem is template structure as of now we are using standard template but when assigned the task they will get like this mail.
Task Email content does not reference to actual task
I got below email, which looks to be not correct
-----Original Message-----
From: ABC (ABC Connections)
Sent: Friday, April 29, 2016 4:42 PM
To: XYZ (ABC Connections)
Subject: A task has been updated
Hello ABC,
Your task has been Completed. Here are the details -
Subject -Test of Auto Email
Status - Completed
Priority - Normal
This should have been followed standard template like below
To: ABC
XYZ has updated the following new task:
Subject: Test of Auto Email
Opportunity: test11
Status - Completed
Priority: Normal
For more details, click the following link:
https://my.salesforce.com/00T22000001nTBP
Can please any one help above template
Thanks in Advance
Email notification when delegated task is complete.:
For the above requirement i have written a one trigger on Task object.That trigger working as expected.But here my problem is template structure as of now we are using standard template but when assigned the task they will get like this mail.
Task Email content does not reference to actual task
I got below email, which looks to be not correct
-----Original Message-----
From: ABC (ABC Connections)
Sent: Friday, April 29, 2016 4:42 PM
To: XYZ (ABC Connections)
Subject: A task has been updated
Hello ABC,
Your task has been Completed. Here are the details -
Subject -Test of Auto Email
Status - Completed
Priority - Normal
This should have been followed standard template like below
To: ABC
XYZ has updated the following new task:
Subject: Test of Auto Email
Opportunity: test11
Status - Completed
Priority: Normal
For more details, click the following link:
https://my.salesforce.com/00T22000001nTBP
Can please any one help above template
Thanks in Advance
Instead of using standard template. Send email from trigger itself. There you set all the details as per your requirement and need.
Please refer this link: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
for sending Outbound Email.
Or either this will help you out.
Hope this will help you out.
Thanks for your help...But I want to know the after completed task status.it should be showing task details in the mail along with the particular Sandbox URL Like...
Your task has been Completed. Here are the details -
Subject -Test of Auto Email
Status - Completed
Priority - Normal
https://my.salesforce.com/00T22000001nTBP
But as of now in my code the above Http Url is not showing.... Clould you please help me that
Thanks again
You can add one more line to add the link in template. (@line no 21 of previous code)Like : Hope this will help you.
Mark this answer as best answer if this solves your need.
The above code working as expected.But i need one more help, here we need to restrict the email notifications to only those tasks created by the specific roles/profiles.How we need to achieve them. Can you please help me on this.
Here the Trigger Code the one which i have using currently :
trigger TaskEmailNotification on Task (before update ) {
Set<Id> ownerIds = new Set<Id>();
for(Task tsk: Trigger.New){
if(tsk.Status=='Completed' && Trigger.oldMap.get(tsk.Id).Status != 'Completed' && tsk.OwnerId != tsk.CreatedById){
ownerIds.add(tsk.CreatedById);
}
}
// Build a map of all users who are assigned the tasks
Map<Id, User> userMap = new Map<Id,User>([select Name, Email from User where Id in :ownerIds]);
List<Messaging.SingleEmailMessage> emailMsglist=new List<Messaging.SingleEmailMessage>();
for(Task tsk : Trigger.New) {
if(tsk.Status=='Completed' && Trigger.oldMap.get(tsk.Id).Status != 'Completed' && tsk.OwnerId != tsk.CreatedById) {
User theUser = userMap.get(tsk.CreatedById);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {theUser.Email};
mail.setToAddresses(toAddresses); // Set the TO addresses
mail.setSubject('A Task has been updated'); // Set the subject
// Next, create a string template. Specify {0}, {1} etc. in place of actual values.
String template = 'Hello {0}, \n\n Your Task has been Completed. Here are the details - \n\n';
// template+= 'taskid -'+tsk.id+' \n';
template+= 'Subject: '+tsk.Subject+' \n';
template+= 'Status: '+tsk.Status +' \n';
template+= 'Priority: '+tsk.Priority +' \n';
template+= '\n\nFor more details, click the following link: \n\n';
template+= URL.getSalesforceBaseUrl().toExternalForm() + '/' + tsk.Id;
List<String> args = new List<String>();
args.add(theUser.Name);
// Here's the String.format()
String formattedHtml = String.format(template, args);
mail.setPlainTextBody(formattedHtml);
emailMsglist.add(mail);
}
}
Messaging.SendEmail(emailMsglist);
}
Thanks
So check the condition before sending email i.e
ProfileId : is the profile throughwhich you want to send the email.
Hope this will help you. Let me know if younedd any othe help.
So check the condition before sending email i.e
ProfileId : is the profile throughwhich you want to send the email.
Hope this will help you. Let me know if younedd any othe help.
We are facing some problem in the above trigger ..as of now the above code is working as expected the problem is here in task object we have some record types are there, in that if we select standard record type the above code is working,if we select some RMA updates,Case record types that time task owner getting the mail like your task has been Completed but hear we want emails are sending to the task who has created instead of sending it to assignee. .can you please help me on this
Thanks
In this case you are sending the email to owner.
Here in your code you have created the set of ownerIds.
The same code we are using the one which you have mentioned above.But my problem is we have some recordtypes in task Object.Like "UPDATE","WEBUPDATE" e.t.c.like that.Hear "Standard" is the default recordtype .If we select default recordtype then trigger working as expected so that time Task assignee getting mail like your "Giri has assigned you the following new task:" Hear Giri is the task Owner, Shyam is the Assignee, after recieving mail shyam.Shyam wants to be changed status inprogress to Completd.after complete the task task owner(Giri) getting mail like this "Your task has been completed". as of now that senario working.
Hear the main problem is in the record type section if selecet any of the other recordtype apart from Standard after assign the task to assignee Shyam getting mails like " Giri has assigned you the following new task" .that time shyam hasn't changing any thing that Task.but Owner (Giri) getting mails is automatic task completion mail.
So how we can acheive them..
Thanks