You need to sign in to do that
Don't have an account?

how to Trigger an email when IDEA is promoted to 30 points
Can any one tell me how to Trigger an email when IDEA is promoted to 30 points?
You need to sign in to do that
Don't have an account?
Can any one tell me how to Trigger an email when IDEA is promoted to 30 points?
your problem is that you do not know how to send email in trigger or how to know when IDEA is promoted to 30 pts|???
thanks for your reply...i know how to send an email by trigger ....i want to know if my idea is promoted to 30 points ,i want to get a mail stating tat my idea has promoted to 30 points..can you plz help me with this?
Can you tell which sobject is used to track the IDEA details?
i have used "votecount"....below is my code..am not sure it works fine
trigger promote on Idea (before insert,before update) {
list <Idea> vote1= new List<Idea>();
Map<Id,Decimal> accConMap= new Map<Id,Decimal>();
for (Idea pro:Trigger.new){
accConMap.put(pro.id, pro.votetotal);
}
system.debug(accConMap);
vote1= [select id, votetotal from idea where id in: accConMap.keyset()];
for(Integer i=0;i < vote1.size();i++){
if(vote1[i].votetotal >= 10){
system.debug(vote1[i]);
system.debug(vote1[i].votetotal);
trigger promote on Idea (before insert,before update) {
list <Idea> vote1= new List<Idea>();
Map<Id,Decimal> accConMap= new Map<Id,Decimal>();
List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
for (Idea pro:Trigger.new){
if(pro.votetotal >= 30)
{
//add your email code here
accConMap.put(pro.id, pro.votetotal); //Check whether you still need this line
}
if(mailList.size() > 0)
{
Messaging.sendEmail(mailList);
}
Let me know if you were looking at something like this or if you have any questions.
i have tried testing with the above code which you have gave..but once my idea is promoted my idea to 30 points am not geting any mail...i have added the mail id too...
String[] toAddresses = new String[] {'.....@yahoo.com'};
i am getting the mail when new idea is posted but why am not geting the mail when the idea has promoted to 30 points?
Instead of before update, use after update event in trigger and see.
i am geting the same error again...
If you are getting any error message, can you post that along with the code and highlight the error line ?
i am not getting any error message but once i promote my idea to 30 points i am not geting any mail...my requirement is that once the idea is promoted to 30 points i should get a mail..
Here is the code which i have written before:
trigger promote on Idea (before insert,before update) {
list <Idea> vote1= new List<Idea>();
Map<Id,Decimal> accConMap= new Map<Id,Decimal>();
for (Idea pro:Trigger.new){
accConMap.put(pro.id, pro.votetotal);
}
system.debug(accConMap);
vote1= [select id, votetotal from idea where id in: accConMap.keyset()];
for(Integer i=0;i < vote1.size();i++){
if(vote1[i].votetotal >= 20){
system.debug(vote1[i]);
system.debug(vote1[i].votetotal);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'my mail id'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('my mail id');
mail.setSenderDisplayName('Idea Support');
mail.setSubject('message : ');
mail.setPlainTextBody('message');
mail.setHtmlBody('message');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
Is it printing the debug statements that are inside the if condition.
Is Votetotal of Decimal type?
what you do is update the if statement
if(Votetotal >= Decimal.valueof(20))
no its not printing ....i guess i went wrong some where in the code...plz help me with this issue..
sobject type is "idea"
when i am posting any new idea i am getting the below log
As per the debug logs Trigger.new does not hold any IDEA records.
Can you check whether it is atleast printing the values when the record is inserted initially?
Hi Imran,
As per my code i am able to track votetotal and idea id in debug log and i am getting mail if i edit or comment on idea which has 30points on it....but my question is cant i get mail once i promote the idea to 30 points?
maybe you will have to use trigger.new and trigger.old,then check if the old value was not 30 pts and if the new value is 30 pts ,then send the mail.