You need to sign in to do that
Don't have an account?
sfdclearn
using Product name in a filter in an account workflow rule
Hi,
I have a workflow rule in the Account object .
if Accountstatus='new'
then this rule triggers an email template to the customer.
Now I would like to include the product name in the workflow.
which includes if(product name='xxx') then send the more specific template.(with the product name included on it).
I believe this cannot be accomplished with a workflow rule as Account can have multiple opportunities and each opportunity is tied to several products.
But is there a way to address this?
Thanks in advance for help!
http://boards.developerforce.com/t5/Apex-Code-Development/using-Product-name-in-a-filter-in-an-account-workflow-rule/m-p/502249#M93067
Madhan Raja M
Hi sfdclearn,
You can done this by writing Trigger(after update) for Account object.
refer following sample trigger:
trigger sendEmail on Account(after update)
{
for(Account a : Trigger.new)
{
if (a.status == 'new')//you can add some more condition here
{
List<Opportunity> aps = [SELECT Id,Email FROM Opportunity WHERE AccountId = :a.Id];
for (Opportunity ap : aps)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(ap.Id);
mail.setTemplateId('your template id here');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
}
reference for sending email using trigger:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound.htm?SearchType=Stem&Highlight=email
but how can we include the product name in the template when we write this trigger