• Claire Sunderland
  • NEWBIE
  • 35 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 13
    Replies
I want to add the ZenDesk tickets visualforce page you can integrate for Salesforce onto a custom object. Does anyone have experience with that?
I am trying to de-activate an apex trigger in production but it keeps failling. I have tried 2 different methods:

1. De-activating in sandbox and pushing to production
2. Using force.com IDE to delete. I am able to delete in my sandbox environment but I keep receiving an error when I try to deploy it to production.

Here is the error:

User-added image 
I'm getting this error when I try to deploy my test class to production: System.AssertException: Assertion Failed: Expected: 005G0000008Mb3iIAC, Actual: 0050f000009KoD2AAK  Stack Trace: Class.TestRRMQL.testRRMQLInsertPriority: line 29, column 1. The actual is coming back as data not available and expected coming back as my user.

Can anyone help?

Here is the class: 

@isTest
private class TestRRMQL {

//-- Tests RoundRobinLeadRoutingMQL.trigger
    static testMethod void testRRMQLInsertPriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales' OR Profile.Name = 'Assoc Account Executive' ) and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'out', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Test.startTest();
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Status = 'MQL Re-engage', Vertical_Industry__c = 'Pilates',
                             Email = 'test@rr.com', Phone = '4085551234', Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111',
                             Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        Test.stopTest();
        
        //requery and assert lead was assigned to user and last lead assignment updated
        lead = [select Id, OwnerId, Owner.Name from Lead where Id = :lead.Id];
        salesUsr = [select Id, Last_Lead_Assignment__c from User where Id = :salesUsr.Id];
        system.assertEquals(lead.OwnerId, salesUsr.Id);
        system.assertEquals(salesUsr.Last_Lead_Assignment__c.Date(), system.today());
    }
    
    
    //-- Tests RoundRobinLeadRoutingMQL.trigger
    static testMethod void testRRMQLUpdatePriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales' OR Profile.Name = 'Assoc Account Executive') and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'inb', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Vertical_Industry__c = 'Pilates', Email = 'test@rr.com', Phone = '4085551234',
                             Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111', Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        
        Test.startTest();
        lead.Status = 'MQL Re-engage'; 
        update lead;
        Test.stopTest();
        
       
       }
       }
Here is the error: System.AssertException: Assertion Failed: Expected: 0050f000008wRZYAA2, Actual: 0050f000009O7CcAAK 
Stack Trace: Class.TestRROutboundYoga.testRROutboundInsertPriority: line 29, column 1

Here is the class:
@isTest
private class TestRROutboundYoga {

//-- Tests RoundRobinLeadRoutingOutbound.trigger
    static testMethod void testRROutboundInsertPriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales Yoga'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales Yoga' ) and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'out', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Test.startTest();
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Status = 'Prospect', Vertical_Industry__c = 'Yoga',
                             Email = 'test@rr.com', Phone = '4085551234', Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111',
                             Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        Test.stopTest();
        
        //requery and assert lead was assigned to user and last lead assignment updated
        lead = [select Id, OwnerId, Owner.Name from Lead where Id = :lead.Id];
        salesUsr = [select Id, Last_Lead_Assignment__c from User where Id = :salesUsr.Id];
        system.assertEQUALS(lead.OwnerId,salesUsr.Id);
        system.assertEquals(salesUsr.Last_Lead_Assignment__c.Date(), system.today());
    }
    
    
    //-- Tests RoundRobinLeadRoutingOutbound.trigger
    static testMethod void testRROutboundUpdatePriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales Yoga'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales Yoga' OR Profile.Name = 'Outbound Team Leader' ) and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'inb', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Vertical_Industry__c = 'Yoga', Email = 'test@rr.com', Phone = '4085551234',
                             Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111', Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        
        Test.startTest();
        lead.Status = 'Prospect';
        update lead;
        Test.stopTest();
        
       
       }
       }


AND HERE IS THE TRIGGER

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
trigger RoundRobinLeadRoutingOutboundYoga on Lead (before insert, before update) {
  
  try{
    //lists to hold all leads of relevant status
    List<Lead> lowLeads = new List<Lead>();
    
    //lists to hold only those leads which should be round robined
    List<Lead> roundRobinLow = new List<Lead>();
    
    Map<Id, User> userMap = new Map<Id, User>(); //map user info by Id
    //lists holding eligible users in order of lead assignment
    List<LowPrioritySort> lowUsers = new List<LowPrioritySort>(); //wrapper class for users implements compareTo on last low priority lead assignment
    List<User> mqlUsers = new List<User>();
    
    //set and list to ensure unique users to update
    Set<Id> userSet = new Set<Id>();
    List<User> userLst = new List<User>();
    
    //if trigger is insert, collect leads inserted with a relevant status
    if(trigger.isInsert){
      for(Lead lead : trigger.new){
        if(lead.Vertical_Industry__c == 'Yoga' && (lead.Status == 'Prospect') ){
          lowLeads.add(lead);
        }
      }
    }
    //if trigger is update, collect leads which have changed to a relevant status
    else if(trigger.isUpdate){
      for(Lead lead : trigger.new){
        if(trigger.oldMap.get(lead.Id).Status != lead.Status ||trigger.oldMap.get(lead.Id).Vertical_Industry__c != lead.Vertical_Industry__c ){
        if(lead.Vertical_Industry__c == 'Yoga' && (lead.Status == 'Prospect') ){
            lowLeads.add(lead);
          }
        }
      }
    }
    
    
    //if leads have been updated to any of the relevant statuses they may be eligible for round robin
    if(lowLeads.size() > 0){
      //query additional user info
      List<User> users = [select Id, ProfileId, Profile.Name, isActive, Available_for_Leads__c, Last_Lead_Assignment__c,
                Last_Low_Priority_Lead_Assignment__c from User
                order by Last_Lead_Assignment__c asc nulls first];
      
      //create a map of all users by Id
      for(User u : users){
        userMap.put(u.Id, u);
      }
      
      //assign users to list of outbound sales agents who are avail for leads
      for(User u : users){
        if( ( u.Profile.Name == 'Outbound Sales Yoga') && u.isActive == true && u.Available_for_Leads__c == true){
          lowUsers.add(new LowPrioritySort(u));
        }
      }
      
      //sort lowUsers list by last low priority lead assignments
      lowUsers.sort();
    }
      
    
    //only round robin low priority leads not already owned by outbound rep
    if(lowLeads.size() > 0){
      for(Lead lead : lowLeads){
        //if lead not already owned by outbound sales agent, add to list to round robin
        if( ( userMap.get(lead.OwnerId).Profile.Name != 'Outbound Sales Yoga') && (userMap.get(lead.OwnerId).Profile.Name != 'Inbound Sales')){
          roundRobinLow.add(lead);
        }
      }
    }
    
    /* ROUND ROBIN LOW PRIORITY LEADS */
    if(roundRobinLow.size() > 0){
      //round robin to available outbound sales agents
      if(lowUsers.size() > 0){
        Integer userIndex = 0; //initialize index
        for(Lead lead : roundRobinLow){
          //assign to current user indexed
          User currUser = lowUsers[userIndex].usr;
          lead.OwnerId = currUser.Id;
          currUser.Last_Lead_Assignment__c = system.now(); //update last lead assignment
          if(!userSet.contains(currUser.Id)){ //check if already in list
            userSet.add(currUser.Id);
            userLst.add(currUser);
          }
          userIndex++; //advance to next user
          if(userIndex >= lowUsers.size()){
            userIndex = 0; //reset index
          }
        }
      }
    }
    
    
    
    //update users if necessary
    if(userLst.size() > 0){
      update userLst;
    }
  }
  catch(Exception e){
    system.debug('EXCEPTION in RoundRobinLeadRouting.trigger: ' + e);
  }
}


Can anyone help me with fixing this line?
When I use /*   */ it get an error --> Error: Compile Error: Unexpected EOF at line 21 column 1.  Can someone tell me why this is?  Here is the code.


global class DeleteAllTask implements Database.Batchable<Sobject>,schedulable{
          
    global Database.queryLocator start(Database.BatchableContext bc)
    {
        String sSOQL = 'Select ID, Status, Subject From Task Where status =\'Completed\' and subject=\'callback\' ' ; 
        if(test.isRunningTest()){
            sSOQL += ' limit 5 ';
        }
            return Database.getQueryLocator(sSOQL);
    }
    global void execute(Database.BatchableContext bc, List<Task> scope){
        Delete scope;
    }            
        global void finish(Database.BatchableContext bc){
    }
        global void execute(SchedulableContext sc){
            DeleteAllTask oDeleteAllTask = new DeleteAllTask();
            Database.executeBatch(oDeleteAllTask,50);
    }
}
trigger DeleteCompletedCallbackTaskTrigger on Task (after update) {
    for (Task task: Trigger.new) {
      if(task.status == 'Completed' && task.subject == 'Callback') {
        delete Task;
    }
  }
}
I'm getting this error when I try to deploy my test class to production: System.AssertException: Assertion Failed: Expected: 005G0000008Mb3iIAC, Actual: 0050f000009KoD2AAK  Stack Trace: Class.TestRRMQL.testRRMQLInsertPriority: line 29, column 1. The actual is coming back as data not available and expected coming back as my user.

Can anyone help?

Here is the class: 

@isTest
private class TestRRMQL {

//-- Tests RoundRobinLeadRoutingMQL.trigger
    static testMethod void testRRMQLInsertPriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales' OR Profile.Name = 'Assoc Account Executive' ) and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'out', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Test.startTest();
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Status = 'MQL Re-engage', Vertical_Industry__c = 'Pilates',
                             Email = 'test@rr.com', Phone = '4085551234', Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111',
                             Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        Test.stopTest();
        
        //requery and assert lead was assigned to user and last lead assignment updated
        lead = [select Id, OwnerId, Owner.Name from Lead where Id = :lead.Id];
        salesUsr = [select Id, Last_Lead_Assignment__c from User where Id = :salesUsr.Id];
        system.assertEquals(lead.OwnerId, salesUsr.Id);
        system.assertEquals(salesUsr.Last_Lead_Assignment__c.Date(), system.today());
    }
    
    
    //-- Tests RoundRobinLeadRoutingMQL.trigger
    static testMethod void testRRMQLUpdatePriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales' OR Profile.Name = 'Assoc Account Executive') and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'inb', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Vertical_Industry__c = 'Pilates', Email = 'test@rr.com', Phone = '4085551234',
                             Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111', Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        
        Test.startTest();
        lead.Status = 'MQL Re-engage'; 
        update lead;
        Test.stopTest();
        
       
       }
       }
trigger DeleteCompletedCallbackTaskTrigger on Task (after update) {
    for (Task task: Trigger.new) {
      if(task.status == 'Completed' && task.subject == 'Callback') {
        delete Task;
    }
  }
}