• subbarao kalavala
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Problem: I have written a trigger that updates cross-object fields. The trigger passes and works, but the test returns 0% code coverage. Can anyone help correct the test?
 
Custom object Fundraise__c  has a lookup relationship to Account object and to Fund_c object. The trigger updates FundABC__c, FundDEF__c and Fund__GHI checkbox fields in Account object with 'true' everytime Fundraise__c gets created or updated with field Fund__c equal to FundABC, FundDEF or FundGHI respectively.
 
Trigger:
 
trigger UpdateAcct on Fundraise__c (after insert, after update) {
   Set<Id> acid = new Set<Id>();
   for(Fundraise__c temp0:Trigger.New) {
      acid.add(temp0.Account__c);
   }
   Map<Id,Account> act = new Map<Id,Account>([Select Id from Account where Id in :acid]);
   Set<Account> acts = new Set<Account>();
   List<Account> acts1 = new List<Account>();
   for(Fundraise__c temp:Trigger.New) {
       if(temp.Fund__c == 'FundABC') {
         if(act.containsKey(temp.Account__c)) {
            Account upd = act.get(temp.Account__c);
              upd.FundABC__c = true ;
            acts.add(upd);
         }
      }
       if(temp.Fund_Copy__c == 'FundDEF') {
         if(act.containsKey(temp.Account__c)) {
            Account upd = act.get(temp.Account__c);
              upd.FundDEF__c = true ;
            acts.add(upd);
         }
      }  
      if(temp.Fund_Copy__c == 'FundGHI') {
         if(act.containsKey(temp.Account__c)) {
            Account upd = act.get(temp.Account__c);
              upd.FundGHI__c = true ;
            acts.add(upd);
         }
      }
   }
   acts1.addAll(acts);
   update acts1;
  }
 
Test:
 
@isTest
public class testUpdateAcct { 
   static testmethod void invokeTrigger() {
      Account ac = new Account();
      ac.Name = 'Test Account';
      Database.SaveResult sr = Database.insert(ac, false);
      if(sr.isSuccess()) {
         Fundraise__c p = new Fundraise__c();
         p.Name = 'Test Fundraise';   
         p.Account__c = sr.getId();
         Database.SaveResult sr1 = Database.insert(p, false);
         if(sr1.isSuccess()) {
            Id pid = sr1.getId();
            Fundraise__c p1 = [Select Id, Name from Fundraise__c where Id =:pid];
            p1.Fund__c = 'FundABC';
            update p1;
            p1.Fund__c = 'FundDEF';
            update p1;
            p1.Fund__c = 'FundGHI';
            update p1;
            p1.Fund__c = '';
            update p1;
         }        
      }
   }
}
I have a business requirement to send email alerts using process builder at a specific time say 7 days after close date of Opportunity @ 9 AM CET
I can send email alerts after 7 days but i dont see any option to send email alert at a specified time of the day. Does any salesforce.com expert exist on this developer board who can answer my query
  • September 21, 2015
  • Like
  • 0
Hi All,

Stuck in a difficult situation at the moment. I have a new record type on Opportunities which is NOT to be included in the Reports. The problem is I have more then 500 reports . I want to be in a situation to add a filter which would would reflect on all the existing reports. Is there a way of doing it . ??????????????????????