• Gyanaloka Panda 8
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
public with sharing class HIV_UserTriggerHandler {
    
    public static void onAfterInsert(List<User> listUserNew){
        HIV_ApexSharing.addMembersToPublicGroup(listUserNew);
        //HIV_ApexSharing.insertContactShareForCP (listUserNew);
    }
}
public with sharing class HIV_ContactTriggerHandler{
public static void onBeforeInsert(List<Contact> lstContactNew,Boolean isInsert, Boolean isUpdate){
        try{
            Id hivAdminId ;
            hivAdminId = HIV_ApexSharing.getHIVAdminUserId();
            List<string> lstAcccntIds=new List<String>();
            List<String> lstRoles=new List<String>{Label.HIVProfilePTM,Label.HIVProfilePM,Label.HIV_OrganizationLead};
            for(Contact oContact : lstContactNew)
            {
                if(isInsert)
                {
                       if(lstRoles.contains(oContact.HIV_Role__c))
                    {
                        oContact.OwnerId=hivAdminId;
                    }
                }
            }
            
        }catch(Exception ex){
               Map<String, Object> mapErrorInfo = ERR_BaseErrorHandler.formatException(HIV_ApexSharing.class.getName(), 'Critical', ex, 'Error to add group member in Public group.');
            String sErrorInfoUpd = JSON.serialize(mapErrorInfo);
            ERR_ApplicationErrorHandler.createErrorLogRecord(sErrorInfoUpd);
        }
        
    }
}