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

how to check the old lead status with new lead lead status in apex class
public with sharing class SendNamerFinacialSdlGroup{
i have the method where i will check the lead (lead records related to group members) owners and status is not changed with in 24 hoursthen i will update the checkbox__x to true.
Currently i have written the code until fetching the leads related to particulr public group of test_Team.Please suggest me how to check the existed old status with new lead status in apex class to process furthur.
public static void updateNamercheckbox(List<Lead> allleadlist){
set<id> useridset=new set<id>();
set<id> leadid=new set<id>();
for(Lead led:allleadlist){
leadid.add(led.ownerId);
}
List<Group> pbgrpid = [select id from Group where type='Regular' AND DeveloperName='test_Team'];
List<GroupMember> userids = [select UserOrGroupId,GroupId from GroupMember where GroupId IN:pbgrpid];
for(GroupMember gmid:userids){
useridset.add(gmid.UserOrGroupId);
}
system.debug('useridset' +leadid);
}
}
i have the method where i will check the lead (lead records related to group members) owners and status is not changed with in 24 hoursthen i will update the checkbox__x to true.
Currently i have written the code until fetching the leads related to particulr public group of test_Team.Please suggest me how to check the existed old status with new lead status in apex class to process furthur.
public static void updateNamercheckbox(List<Lead> allleadlist){
set<id> useridset=new set<id>();
set<id> leadid=new set<id>();
for(Lead led:allleadlist){
leadid.add(led.ownerId);
}
List<Group> pbgrpid = [select id from Group where type='Regular' AND DeveloperName='test_Team'];
List<GroupMember> userids = [select UserOrGroupId,GroupId from GroupMember where GroupId IN:pbgrpid];
for(GroupMember gmid:userids){
useridset.add(gmid.UserOrGroupId);
}
system.debug('useridset' +leadid);
}
}
i changed your code a bit to get old values, in the argument you need to pass trigger.oldMap and your work is done:
Please let me know if it works for you.
i have changed the logic and working fine now.
now i want to send email when Checkbox__c false in workflow and default value is unchecked.But again here issue is timedependent workflow will run and consider all the leads where Checkbox__c false.so any idea how to fix that i want to raise this workflow only for test_team group leads.
only thing i can do is hardcode the users names of group and put in rule criteria.
public static void updateNamercheckbox(List<Lead> allleadlist,Map<id,Lead> oldLeadMap){
set<id> useridset=new set<id>();
List<Group> pbgrpid = [select id from Group where type='Regular' AND DeveloperName='test_Team'];
List<GroupMember> userids = [select UserOrGroupId,GroupId from GroupMember where GroupId IN:pbgrpid];
for(GroupMember gmid:userids){
useridset.add(gmid.UserOrGroupId);
}
for(Lead led:allleadlist){
if((useridset.contains(oldLeadMap.get(led.id).OwnerId))&&((led.Status != oldLeadMap.get(led.Id).Status)||(led.OwnerId!= oldLeadMap.get(led.Id).OwnerId))){
Checkbox__c=TRUE;
}
else{
Checkbox__c=FALSE;
}
}
}
i have tried but the issue is with send notificstions to gropu of users.
Is your Group is dynamic or fix. I am adding snapshot from Salesforce. Salesforce support send email group of user. (Team, Group, Role) based on Object
~Thanks
Onkar Kumar