You need to sign in to do that
Don't have an account?
Tillu
Sending Email Missfire?
I have created a field "userassigne" to account object .this field is lookup to User. And i have writtened a workflow that if "Userassigne" equals Null. then email alert to send an email to selected user from lookup.
I have added all users in the Selected List in workflow email alert.
while creating new record i have given 1 user in Userassigne field. But the email sent to all users why.
So i have removed all users and given only one user in selected list in workflow. Again when i am trying to send a mail even what ever the user that i have selected the email sent to only one person which i have added in selected list in workflow.
How to solve. what ever the user that i have selected in lookup, the email should be sent to that user only.?
I have added all users in the Selected List in workflow email alert.
while creating new record i have given 1 user in Userassigne field. But the email sent to all users why.
So i have removed all users and given only one user in selected list in workflow. Again when i am trying to send a mail even what ever the user that i have selected the email sent to only one person which i have added in selected list in workflow.
How to solve. what ever the user that i have selected in lookup, the email should be sent to that user only.?
Workflow does not have the feature to Dynamically Check the User which is assigned and Send email only to that user.
You have to use a Trigger.
Regards,
Ashish
/*************
*******Created by:Nirmal Christopher
*******Created Date:02.05.2013
*******Description:Email will be sent if the owner is changed to new owner and old owner of the respective lead record
*************/
trigger SendEmailOnOwnerChange on Lead (before update,After Update) {
if (trigger.old[0].OwnerId != trigger.new[0].OwnerId ) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//Select the Email Address of the old owner
String emailAddrnew = [select Email from User where Id = :trigger.old[0].OwnerId].Email;
String emailAddrold = [select Email from User where Id = :trigger.new[0].OwnerId].Email;
//Select the new owner and old owner from user
String newOwnerName = [select Name from User where Id = :trigger.new[0].OwnerId].Name;
String oldownerName=[select name from User where Id =:trigger.old[0].OwnerId].Name;
//Store the email address
String[] emailAddrnew1 = new String[] {emailAddrnew};
String[] emailAddrold1 = new string[]{emailAddrold};
mail.setToAddresses(emailAddrnew1 );
mail.setCcAddresses(emailAddrold1 );
mail.setSubject('Owner Changed for Lead : ' + trigger.new[0].Name);
mail.setPlainTextBody('Owner of lead: ' + oldownerName + ' Changed to ' + newOwnerName);
mail.setHtmlBody('This is to notify that the Owner of lead: https://ap1.salesforce.com/ <b>' + trigger.new[0].Id+'<b> Changed from</b> '+oldownerName + '</b> Changed to <b>' + newOwnerName + '</b>');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
If the userassigne field is a lookup(User) field.
Firsr remove all the Users selected in the work flow Email alert . then follow the below steps.
then you can choose the same field in Workflow Email Alert "Choose Related User" in Recepient Type. you will be seeing the "userassigne" listed in the available recepients section. move the field to the Selected Recepients section and you are done. now you can test. you will see the email sent to the user selected in the "userassigne" only.
if you are facing any difficulties let me know. if it works then mark this as solution.
Thanks