You need to sign in to do that
Don't have an account?
Rahul
I have to send Email Alerts to those users whose Account has no Activity for more than than 15 days.
I have to send Email Alerts to users where no Account Activity greater than 15 days. I have a Field of No activity since which calculates it. It gives the count which I have made based on formula. Now my requirement is I need to send Email Alerts to salesperson where No activity since greater than 15. My logic is i have created a text field Named Activitystatus field and created a work flow rule based on that text field named Activitystatus . In the rule I have given criteria that when Activitystatus equals NoActivity, send an Email Alert to Users.Now, Using the trigger i want to make the Activity status as No Activity for those accounts where No activity since greater than 15. When Activity status Equals NoActivity the Workflow Rule will fire Automatically.
I have used this Logic but its not Working.
trigger NoActivityAccount on Account(before insert) {
List<Account> objvrList =[select Id,Activity_status__c from Account where No_Activity_since__c > 15];
boolean flagetoUpdate = false ;
for(Account ac :trigger.new){
if(ac.name != null)
{
flagetoUpdate = true ;
}
}
if(flagetoUpdate){
for(Account acc : objvrList) {
acc.Activity_status__c ='No Activity' ;
}
update objvrList ;
}
}
I have used this Logic but its not Working.
trigger NoActivityAccount on Account(before insert) {
List<Account> objvrList =[select Id,Activity_status__c from Account where No_Activity_since__c > 15];
boolean flagetoUpdate = false ;
for(Account ac :trigger.new){
if(ac.name != null)
{
flagetoUpdate = true ;
}
}
if(flagetoUpdate){
for(Account acc : objvrList) {
acc.Activity_status__c ='No Activity' ;
}
update objvrList ;
}
}
All Answers
Secondly you are creating one more redundant field Activity_Status__c which is used just to indicate that Account is been inactive for 15 days which you can already get from your formula field.
Thirdly you can accomplish this entire requirement in process builder(Workflow) alone without the trigger.
Build process builder on Account when any update happens on account record. with criteria to check No_Activity_since__c>15 and then add immediate action to send email.
If it helped you to solve your problem please mark as best answer