• nickboeka
  • NEWBIE
  • 0 Points
  • Member since 2012

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

I'm a little stumped on why a trigger I already have deployed in production, is now throwing validation errors when I am trying to deploy a brand new class from my sandbox to prod.  I am getting an error that this trigger needs at least 1% of code covereage, and that I currently have 0.  Trigger is below.  Can someone help me either with a test class that will satisfy the requirement, or what the process is to satisfy the requirement.  thanks in advance for the help

 

trigger TaskFields on Task (before insert, before update) {

    String stringId;
    String subjectId;
       Set<Id> contactsToQuery = new Set<Id>();
    for(Task t : Trigger.new){
        stringId = '' + t.WhoId;
        subjectId = t.subject;
                    contactsToQuery.add(t.WhoId);}        
    if(stringId.substring(0,3) == '003' && subjectId.startsWith('URGENT:')){        
        
    
    for(Task t : Trigger.new){
    Map<Id,Contact> conMap = new Map<Id,Contact>([select Id, AccountId, Account.Name, Owner.Name, Account.Customer_Type__c, 
                             Account.BillingState, Approved_Employer_Rep__c, OwnerId, Owner.Team__c, mkto2__Lead_Score__c,
                             mkto_si__Last_Interesting_Moment_Desc__c, mkto_si__Last_Interesting_Moment_Date__c, Account.Count_of_Open_Active_Ops__c 
                             from Contact where Id in : contactsToQuery]);
    
        
    
        if(conMap.containsKey(t.WhoId)){
            t.AccountID__c= conMap.get(t.WhoId).AccountId;
            t.Account_Name__c=conMap.get(t.WhoId).Account.Name;
            t.Customer_Type__c=conMap.get(t.WhoId).Account.Customer_Type__c;
            t.Account_Billing_State__c=conMap.get(t.WhoId).Account.BillingState;
            t.FEA_Approved__c=conMap.get(t.WhoId).Approved_Employer_Rep__c;
            t.Team__c=conMap.get(t.WhoId).Owner.Team__c;
            t.Account_Owner__c=conMap.get(t.WhoId).Owner.Name;
            t.Lead_Score__c=conMap.get(t.WhoId).mkto2__Lead_Score__c;
            t.Last_Interesting_Moment_Date__c=conMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Date__c;
            t.Last_Interesting_Moment_Desc__c=conMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Desc__c;
            t.Active_Account_Opportunities__c=conMap.get(t.WhoId).Account.Count_of_Open_Active_Ops__c;
            
        }
        if( t.Active_Account_Opportunities__c>0 || t.Customer_Type__c == 'Partner' ){
            
            t.OwnerId = conMap.get(t.WhoId).OwnerId;
            }
    }
    }
    else if (stringId.substring(0,3) == '00Q'){
    Set<Id> leadsToQuery = new Set<Id>();
    for(Task t : Trigger.new){
        stringId = '' + t.WhoId;
            leadsToQuery.add(t.WhoId);
    }
    
    Map<Id,Lead> leadMap = new Map<Id,Lead>([select Id, OwnerId, Owner.Name, Company,mkto2__Inferred_State_Region__c,Approved_Employer_Rep__c, mkto2__Lead_Score__c,
                             mkto_si__Last_Interesting_Moment_Desc__c, mkto_si__Last_Interesting_Moment_Date__c,State from Lead where Id in : leadsToQuery]);
    
    for(Task t : Trigger.new){
        if(leadMap.containsKey(t.WhoId)){
            
            t.Account_Name__c=leadMap.get(t.WhoId).Company;
            t.Account_Billing_State__c=leadMap.get(t.WhoId).mkto2__Inferred_State_Region__c;
            t.FEA_Approved__c=leadMap.get(t.WhoId).Approved_Employer_Rep__c;
            t.Account_Owner__c=leadMap.get(t.WhoId).Owner.Name;
            t.Lead_Score__c=leadMap.get(t.WhoId).mkto2__Lead_Score__c;
            t.Last_Interesting_Moment_Date__c=leadMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Date__c;
            t.Last_Interesting_Moment_Desc__c=leadMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Desc__c;
        }
      IF(t.Account_Billing_State__c == '' ){
      t.Account_Billing_State__c=leadMap.get(t.WhoId).state;
      }
    }
}
}

We have some custom apex coding in place on our SFDC environment and use several integrations.  One of the main issues I am having as our administrator is ensuring that Contact Owners match the Account Owners.  

 

One of our cusom codings is a VF page where our managers can select from a series of criteria, and populate a list of accounts that match that criteria, and then re-assign them in bulk to a new account owner.  Unfortunately, since this is a bulk update, it doesn't follow the typical re-assignment process by re-assigning oppy and contact owners along with the account owner update.

 

I am looking for a trigger that sits on top of everything, that examines on each account update, whether the contact owners match the account owner, and if it doesn't.....updates the contact owner accordingly.  I have searched out some examples, but nothing seems to fit this exact mold, and am turning to the DevForce for help.....

 

 

I'm a little stumped on why a trigger I already have deployed in production, is now throwing validation errors when I am trying to deploy a brand new class from my sandbox to prod.  I am getting an error that this trigger needs at least 1% of code covereage, and that I currently have 0.  Trigger is below.  Can someone help me either with a test class that will satisfy the requirement, or what the process is to satisfy the requirement.  thanks in advance for the help

 

trigger TaskFields on Task (before insert, before update) {

    String stringId;
    String subjectId;
       Set<Id> contactsToQuery = new Set<Id>();
    for(Task t : Trigger.new){
        stringId = '' + t.WhoId;
        subjectId = t.subject;
                    contactsToQuery.add(t.WhoId);}        
    if(stringId.substring(0,3) == '003' && subjectId.startsWith('URGENT:')){        
        
    
    for(Task t : Trigger.new){
    Map<Id,Contact> conMap = new Map<Id,Contact>([select Id, AccountId, Account.Name, Owner.Name, Account.Customer_Type__c, 
                             Account.BillingState, Approved_Employer_Rep__c, OwnerId, Owner.Team__c, mkto2__Lead_Score__c,
                             mkto_si__Last_Interesting_Moment_Desc__c, mkto_si__Last_Interesting_Moment_Date__c, Account.Count_of_Open_Active_Ops__c 
                             from Contact where Id in : contactsToQuery]);
    
        
    
        if(conMap.containsKey(t.WhoId)){
            t.AccountID__c= conMap.get(t.WhoId).AccountId;
            t.Account_Name__c=conMap.get(t.WhoId).Account.Name;
            t.Customer_Type__c=conMap.get(t.WhoId).Account.Customer_Type__c;
            t.Account_Billing_State__c=conMap.get(t.WhoId).Account.BillingState;
            t.FEA_Approved__c=conMap.get(t.WhoId).Approved_Employer_Rep__c;
            t.Team__c=conMap.get(t.WhoId).Owner.Team__c;
            t.Account_Owner__c=conMap.get(t.WhoId).Owner.Name;
            t.Lead_Score__c=conMap.get(t.WhoId).mkto2__Lead_Score__c;
            t.Last_Interesting_Moment_Date__c=conMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Date__c;
            t.Last_Interesting_Moment_Desc__c=conMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Desc__c;
            t.Active_Account_Opportunities__c=conMap.get(t.WhoId).Account.Count_of_Open_Active_Ops__c;
            
        }
        if( t.Active_Account_Opportunities__c>0 || t.Customer_Type__c == 'Partner' ){
            
            t.OwnerId = conMap.get(t.WhoId).OwnerId;
            }
    }
    }
    else if (stringId.substring(0,3) == '00Q'){
    Set<Id> leadsToQuery = new Set<Id>();
    for(Task t : Trigger.new){
        stringId = '' + t.WhoId;
            leadsToQuery.add(t.WhoId);
    }
    
    Map<Id,Lead> leadMap = new Map<Id,Lead>([select Id, OwnerId, Owner.Name, Company,mkto2__Inferred_State_Region__c,Approved_Employer_Rep__c, mkto2__Lead_Score__c,
                             mkto_si__Last_Interesting_Moment_Desc__c, mkto_si__Last_Interesting_Moment_Date__c,State from Lead where Id in : leadsToQuery]);
    
    for(Task t : Trigger.new){
        if(leadMap.containsKey(t.WhoId)){
            
            t.Account_Name__c=leadMap.get(t.WhoId).Company;
            t.Account_Billing_State__c=leadMap.get(t.WhoId).mkto2__Inferred_State_Region__c;
            t.FEA_Approved__c=leadMap.get(t.WhoId).Approved_Employer_Rep__c;
            t.Account_Owner__c=leadMap.get(t.WhoId).Owner.Name;
            t.Lead_Score__c=leadMap.get(t.WhoId).mkto2__Lead_Score__c;
            t.Last_Interesting_Moment_Date__c=leadMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Date__c;
            t.Last_Interesting_Moment_Desc__c=leadMap.get(t.WhoId).mkto_si__Last_Interesting_Moment_Desc__c;
        }
      IF(t.Account_Billing_State__c == '' ){
      t.Account_Billing_State__c=leadMap.get(t.WhoId).state;
      }
    }
}
}

Is there a way to change the Finish button default on a VWF run from a custom button URL that's not referencing a VFP?  Basically I have a simple flow that starts with a button click from a detail page, which opens a new browser window and shows some data along with the standard VWF Finish button. 

 

What I'd like is for finish to close the window, not restart the workflow.