• Tom Blamire 8
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hi,

In our org we have had to create a custom VF Page for all activities due to the complexity of our business. On the account page it always defaults to show Open Activities but i need to revert this to show only Activity history. Does anyone know off the top of their head what the line of code would be setting this as the default?
Hi,

I'm new to all this and need some urgent help. I found a trigger that i modified in our sandbox which works fine. The problem i am having is i do not know how to create a test so i can push it to production. Can you help?

The code is:
 

trigger Guest_Relations_CaseTeamTrigger on Case (after insert) {

    Map<Id, CaseTeamMember> membersToAdd = new Map<Id, CaseTeamMember>();
    List<Case> cases = [Select Id,OwnerId,RecordTypeId,RecordType.Name
                  from Case where id IN :Trigger.newMap.keySet()];
    for (Case c : cases) {
    
      if (c.RecordType.Name == 'Geneva Guest Relations' ||                        
            c.RecordType.Name == 'Guest Relations') {
           
        membersToAdd.put(c.Id, 
          new CaseTeamMember(                   
            ParentId = c.Id,                           
            MemberId = UserInfo.getUserId()
          )
        );
        System.debug('*******************************************');  
        System.debug('User = '+UserInfo.getName());
        
        System.debug('*******************************************');  
      }
    }
    
    if (!membersToAdd.isEmpty()) {
      try {
        CaseTeamRole caseTeamRole = [SELECT Id FROM CaseTeamRole WHERE Name = 'Creator' LIMIT 1];

        for (CaseTeamMember ctm : membersToAdd.values()) {
          ctm.TeamRoleId = caseTeamRole.Id;
        }
      
        for (CaseTeamMember ctm : [SELECT Id, MemberId, ParentId
                       FROM CaseTeamMember
                       WHERE ParentId IN :membersToAdd.keySet()
                       AND MemberId = :UserInfo.getUserId()
                       ORDER BY ParentId]) {
        System.debug('*******************************************');  
        System.debug('User = '+UserInfo.getName());
        
        System.debug('*******************************************');               
          if (membersToAdd.containsKey(ctm.ParentId)) {
            membersToAdd.remove(ctm.ParentId);
          }
        }
        
        if (!membersToAdd.isEmpty()) {
          insert membersToAdd.values();
        }
      } catch (System.QueryException qe) {}
    }
  
}