• TBouscal
  • NEWBIE
  • 85 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 22
    Replies
Please help me for Writing Test Class on Trigger
trigger ParentToCaseClosure on Case (after update,before update) {
  
    
   
    if(trigger.isAfter && trigger.isUpdate) {
     
      

        List<Case> childrenToUpdate = new List<Case>();
        Set<Id> parentIds = new Set<Id>();
        for(Case p:trigger.new) {
        system.debug('******CASE ID ::::'+ p.id);
            case old=trigger.oldMap.get(p.id);
            if(p.IsClosed == TRUE ) {
                    
            
            
                
                parentIds.add(p.Id);
              
                 
               
        }
       
        System.debug('------------- Parent Ids -------- ' + parentIds);
        if(parentIds.size() > 0) {
            for(Case ch : [SELECT Id, Status, Parent.Status FROM Case WHERE Parent.Id IN :parentIds]) {
                 if(ch.Status=='Closed Successful')
                 { system.debug('--no update');}
                ch.Status = ch.Parent.Status;
                childrenToUpdate.add(ch);
            }
           
            System.debug('---------------- Child Case(s) Received : ' + childrenToUpdate.size());           
            try{
                System.debug('---------Going to update the children');
                update childrenToUpdate;
                System.debug('---------Children updated successfully');
            }
            catch(Exception e) {
                System.debug('--------------Exception in updating all the Parents');
            }
        }
        } 
}
    }
Please Write Test Class for Trigger.
Have a requirement to post the first article number selected for a Case to a field on the Case.

I have a query that works but I can't access the article number to put into a map with the CaseID.
 
myCase=[SELECT CaseId, knowledgearticle.articlenumber 
FROM CaseArticle 
WHERE CaseId in :cs LIMIT 1]; 
        // query works in dev console

        For(CaseArticle eca:myCase){
            CaseArticleMap.put(eca.CaseId, eca.knowledgearticle.articlenumber); 
        }  // error: Variable does not exist: articlenumber

Any suggestions?
Hello world!

What am I overlooking?  
When I run my test I can see the debug line stating that the send was successful but my assertion fails because the expected task record doesn't exist.  
For (Contact c:myRecipients){
                    Id EvId = EventMap.get(c.id);
                    String theMsg = ('Please click the link below, or copy and paste into your browser to complete a brief survey ');
                    theMsg = theMsg + ('related to your recent interaction with an Acme service representative. \n \n '); 
                    theMsg = theMsg + ('http://www.acmewidgets.com/survey?iv=xfjtzd9uazro&q1=' + EvId + '&q2=' + c.id);
                    System.debug(theMsg);
                    
                    Messaging.SingleEmailMessage myEmail = new Messaging.SingleEmailMessage();
                    myEmail.setSenderDisplayName(owa.DisplayName); 
                    myEmail.setReplyTo(owa.Address);
                    System.debug('c.id = ' + c.id); 
                    myEmail.setTargetObjectId(c.id);
                    myEmail.setUseSignature(false); 
                    myEmail.setSubject('Please complete this survey from Acme');
                    myEmail.setPlainTextBody(theMsg);
                    myEmail.setSaveAsActivity(true);
                    
                    Messaging.SingleEmailMessage[] theMessages = new List<Messaging.SingleEmailMessage>{myEmail};
                        Messaging.SendEmailResult[] results = Messaging.sendEmail(theMessages);  
                    
                    
                    if (results[0].success){
                        System.debug('The email was sent'); 
                    } else {
                        System.debug('The email failed to send: ' + results[0].errors[0].message);
                    }
                    
                }

 
Attempting to track down an issue where I get "List has no rows...".
I've added some debug lines to my trigger and what's throwing me for a loop is the message is occuring within the trigger where there is no code and no calls to anything.
if(Trigger.isBefore && Trigger.isInsert){
System.debug('Case.Trigger.isBefore && Case.Trigger.isInsert');         
    }
    if(Trigger.isAfter && Trigger.isUpdate) {
System.debug('Case.Trigger.isAfter && Case.Trigger.isUpdate');
The debug line showing the isBefore && isInsert shows in the log, then the error, then the isAfter && isUpdate.

User-added image

Is there a way, without going through every trigger & class, to track where the issue is occurring?
I'm having trouble figuring out how to accomplish a project.
Requirements are, when closing a Case, review some fields, review the Tasks that exist on that Case and if there is not a match within the previous 8 hours send a specific email template to the Contact on the Case.

I'm not looking for the code necessarily just an idea on how the flow of the process should run.  I suspect simply adding a column to an existing list or creating the list with one more column than my query returns to populate after would be sufficient.

What I have so far is, take trigger.new and pass it to a class
Check those Cases for Contact Ids and field values and add them to a new List when they meet the requirements 
I'd like to simply append the template name to the list but don't know how to add a column to the new list.
If I can do that I can then send the messages.  

Thanks in advance for your feedback!
 
How do I access the value of an account field from a Case trigger?  This code produces the above error when I type it in but still saves.  When the test runs the debug message shows the case.accountid field has a value but the case.account.id does not.
 
public static testmethod void testSuccess(){
        Account myAcct = createAccount();
        Contact myCont = createContact(myAcct);
        Case myCase = createCase(myAcct,myCont);
        System.debug('*** Case.Accountid = ' + myCase.accountid + ' Case.Account.Id=' + myCase.Account.Id);
        myCase.Status='Closed';
        update myCase; 
        
    }

 
I would like to understand how to add items to a wrapper, this doesn't compile.  I get Variable does not exist for each item in the list. I'm also at a loss for how to create an index that directly relates to the Case
 
public class TESTING {
    
    public class temptable{
        public Id cId{get;set;}
        public Case Case_obj{get;set;}    
        public Account Account_obj{get;set;}
        public Contact Contact_obj{get;set;}
        public string Email_DevName{get; set;}
    }
    
    public static void theCases(Case[] cs)  {
        
        List<temptable> temptable = new List<temptable>();
        
        String strTitle = '';
        String strReason = ''; 
        String strDetail = ''; 
        String strProduct = ''; 
        
        For (Case c:cs){
            temptable.cid = c.id;
            temptable.Case_obj = c;
            temptable.account_obj = c.Account;
            temptable.Contact_obj = c.Contact;
            
            if(c.Reason == 'Hot'){temptable[c].Email_DevName = 'Hot';}
            else if(c.Reason == 'Cold'){temptable[c].Email_DevName = 'Cold';}
            else {} // do nothing
        }
    }
}

 
Attempting to create a validation rule that insures the end user closing a Case has already entered a Comment on that Case but I can't seem to get the map to work correctly.  Here's what I have in the trigger; 
trigger Cases on Case (<etc>){

    if(Trigger.isBefore && Trigger.isUpdate){

             CloseValidation.CheckValidation(Trigger.new); 

    }
}
and here's the class; 
public class CloseValidation {
    public static void CheckValidation(Case[] cs) 
    {
        if(UserInfo.getProfileId()!='00e30000000d2ft'){ // bypass for Salesforce Administrator profile //
            map<Id, CaseComment> CaseCommentMap = new map<Id, CaseComment>();
            Id thisUser = UserInfo.getUserId();
            
            for (Case c:cs){
                if(c.Status=='Closed' && c.RecordTypeId=='01270000000Q9E1'){
                    CaseCommentMap.Put(c.id,null);
                }
            }
            CaseCommentMap.remove(null);
            CaseCommentMap.putAll([Select Id FROM CaseComment Where ParentId in : CaseCommentMap.keyset() AND CreatedById =:thisUser]);
            
            // if CaseCommentMap has a null for the CaseComment then error
            for(Case c:cs){
                if(!CaseCommentMap.containsKey(c.id) && c.Status=='Closed'){
                    // no key - fail
                    c.addError('You must have commented to close the case (CaseValidation.apx) ' + c.id );         
                } else {
                    // has key - pass
                }
            }      
        }
    }
}

What am I overlooking?
 
I've read a dozen or so questions and answers related to changing the color of a button in a VF page.  Most suggest using a style, some suggest using javascript.  Neither are working for me.  Are there other ways to change the color of an Apex:commandButton?

Javascript:
<script>
        function setColor(btn,color){
        var count=1;
        var property = document.getElementById(btn);
        if (count == 0){
            property.style.backgroundColor = "#FFFFFF"
            count=1;
        }
        else {
            property.style.backgroundColor = "#000000"
            count=0;
        }
    }
    </script>



VF Page button:
<apex:commandButton id='myButton'
                                    style="position:fixed;
                                           bottom:0px;
                                           right:0px;
                                           padding:5px 10px;
                                           color:#FFFFFF;
                                           border-color:#6C8049;
                                           background:#89B32B;
                                           font-weight:bold;
                                           font-size:13px;
                                           line-height:18px;"
                                    onmouseover="setColor('myButton','#A2CA45');"
                                    onmouseout="setColor('myButton','#89B32B');"
                                    value="Create" title="Create" action="{!createCase}" />

This is almost the last component of a project, I'd love to wrap it up soon.

 
Trying to familiarize myself with extensions so I can eventually create a VF page to display the active territory members for each territory an account belongs in.  I'm starting from scratch, straight out of the work book and not having ANY luck.

VF page called TerritoryMembership
<apex:page StandardController="Account" Extensions="TerritoryList">  
{!Title}
</apex:page>
Apex extension
public class TerritoryList {
    private final Account acct; 
    
    public TerritoryList(ApexPages.StandardController controller) {
        this.acct = (Account)controller.getRecord();
        }
    public String getTitle() {
        return 'Account: ' + acct.name + ' (' + acct.id + ')';
        }
}
These are directly from the VF workbook and I get an error message, System.SObjectException: SObject row was retrieved via SOQL without querying the reqested field: Account.Name Class.TerritoryList.getTitle: line8, column 1 (underlined above)

I am accessing the page using a URL with ../apex/Territorymembership?id=accountid

What am I missing?
Hi, I was looking to update my sales pipeline to not include those opportunities that are STAGE: Demo 1 and STATUS: Scheduled, as they haven't occured yet.

As it is, my reporting is currently like this;
User-added image
This categorizes opportunities according to the stage they're in, but I want to exclude those that are in First Demo that have an additional custom field on them called "Status" with the value "Scheduled", because right now they're skewing my numbers and making it look like I have lots of opportunities sitting in demo 1 when they've moved down my sales process.

Any help appreciated!
Please help me for Writing Test Class on Trigger
trigger ParentToCaseClosure on Case (after update,before update) {
  
    
   
    if(trigger.isAfter && trigger.isUpdate) {
     
      

        List<Case> childrenToUpdate = new List<Case>();
        Set<Id> parentIds = new Set<Id>();
        for(Case p:trigger.new) {
        system.debug('******CASE ID ::::'+ p.id);
            case old=trigger.oldMap.get(p.id);
            if(p.IsClosed == TRUE ) {
                    
            
            
                
                parentIds.add(p.Id);
              
                 
               
        }
       
        System.debug('------------- Parent Ids -------- ' + parentIds);
        if(parentIds.size() > 0) {
            for(Case ch : [SELECT Id, Status, Parent.Status FROM Case WHERE Parent.Id IN :parentIds]) {
                 if(ch.Status=='Closed Successful')
                 { system.debug('--no update');}
                ch.Status = ch.Parent.Status;
                childrenToUpdate.add(ch);
            }
           
            System.debug('---------------- Child Case(s) Received : ' + childrenToUpdate.size());           
            try{
                System.debug('---------Going to update the children');
                update childrenToUpdate;
                System.debug('---------Children updated successfully');
            }
            catch(Exception e) {
                System.debug('--------------Exception in updating all the Parents');
            }
        }
        } 
}
    }
Please Write Test Class for Trigger.
Hello world!

What am I overlooking?  
When I run my test I can see the debug line stating that the send was successful but my assertion fails because the expected task record doesn't exist.  
For (Contact c:myRecipients){
                    Id EvId = EventMap.get(c.id);
                    String theMsg = ('Please click the link below, or copy and paste into your browser to complete a brief survey ');
                    theMsg = theMsg + ('related to your recent interaction with an Acme service representative. \n \n '); 
                    theMsg = theMsg + ('http://www.acmewidgets.com/survey?iv=xfjtzd9uazro&q1=' + EvId + '&q2=' + c.id);
                    System.debug(theMsg);
                    
                    Messaging.SingleEmailMessage myEmail = new Messaging.SingleEmailMessage();
                    myEmail.setSenderDisplayName(owa.DisplayName); 
                    myEmail.setReplyTo(owa.Address);
                    System.debug('c.id = ' + c.id); 
                    myEmail.setTargetObjectId(c.id);
                    myEmail.setUseSignature(false); 
                    myEmail.setSubject('Please complete this survey from Acme');
                    myEmail.setPlainTextBody(theMsg);
                    myEmail.setSaveAsActivity(true);
                    
                    Messaging.SingleEmailMessage[] theMessages = new List<Messaging.SingleEmailMessage>{myEmail};
                        Messaging.SendEmailResult[] results = Messaging.sendEmail(theMessages);  
                    
                    
                    if (results[0].success){
                        System.debug('The email was sent'); 
                    } else {
                        System.debug('The email failed to send: ' + results[0].errors[0].message);
                    }
                    
                }

 
I would like to great everyone there. This is my very first post in this forum. I am facing a real problem. I am responsible for developing on Salesforce for an NGO and begin using Salesforce for 8 months. So I am realy new.

I have learned about the system limitations, such as governor limits. Apex best practice, avoid SOQL queries or DMl code in for/while loop.

So, I try to do my best. but, I am facing a real probleme that I have to explain a litle bit. For an NGO, it is import to report monthly to the donors. It comes to my boss this idea to automatically generate indicators values as the projects progress. as a matter of fact, every single time a user insert/update/delete a record, the related indicator must be update. so far, so good. the problem comes when we consider that the organization produces a very high quantity of informations. so, it's impossible to insert then one by oneusing forms. So we need to implement mass Edit/update or import with CSV file. Which is good. There is alot of indicators, so, when an action trigger on an object, it is very important that the related indicator be created or updated for the precise month. Thus, I use the following code 

A) Utility Class I use to handle some functions that I need for all trigger handlers
public class UtilitiesRecordTrack {
	   
   Public static double getPercent(integer numerateur, integer denominateur)
   {
       return (double) denominateur > 0 ? (( (double) numerateur / (double) denominateur ) * 100) : 0;
   }
    
   public static ID getProjectID(String projectName)
    {
        ID projectId = [SELECT Id FROM Project_1__c WHERE Name = : projectName].Id;
        return projectId;
    }
    
    public static List<Indicator_1__c> getIndicator(String indicatorFullName, String projectName)
    {
        Indicator_1__c[] indicator = [SELECT Id, Indicator_Full_Name__c, Related_Project__c
                                                 FROM Indicator_1__c 
                                                 WHERE Indicator_Full_Name__c =: indicatorFullName
                                                 AND Related_Project__c =: getProjectID(projectName)
                                     ];
        return indicator;
    }
    
    public static List<Track_Indicator__c> getTrackIndicatorId(ID indicatorId, Decimal monthNumber, ID operationId)
    {
        return [SELECT Id FROM Track_Indicator__c WHERE Indicator_Id__c = 
                                                  :indicatorId
                                                   AND Month_Number__c = : monthNumber 
                                                   AND Operation_Name__c = : operationId]; 
    }
    
    public static List<Track_Indicator__c> getTrackIndicatorId(String indicatorFullName, Decimal monthNumber, ID operationId, String projectName)
    {
        return [SELECT Id, Indicator_Id__r.Indicator_Full_Name__c, Indicator_Id__r.Related_Project__c, Indicator_Id__c FROM Track_Indicator__c
                                                   WHERE Indicator_Id__r.Indicator_Full_Name__c = :indicatorFullName
                                                   AND Indicator_Id__r.Related_Project__c = :[SELECT Id FROM Project_1__c WHERE Name =:projectName]
                                                   AND Month_Number__c = : monthNumber 
                                                   AND Operation_Name__c = : operationId]; 
    }

    public static void recordOrUpdate(List<Track_Indicator__c> trackToUpdate, Decimal actual, Date d, ID i, ID o)
    {
            System.debug('Function clalled');
           if(trackToUpdate.size() > 0)
           {
              trackToUpdate[0].Actual__c = actual;
              trackToUpdate[0].Date__c =  d;
              update trackToUpdate;
              System.debug('Updated');
            }else{
                 Track_Indicator__c newTrack = new Track_Indicator__c();
                 newTrack.Actual__c = actual;
                 newTrack.Date__c = d;
                 newTrack.Indicator_Id__c = i;
                 newTrack.Operation_Name__c = o;
                 insert newTrack;
                 System.debug('Inserted');
             }
     }
    
    public static void UpdateTrack(Track_Indicator__c trackToUpdate, Decimal actual, Date d, ID o)
    {
       trackToUpdate.Actual__c = actual;
       trackToUpdate.Date__c =  d;
       trackToUpdate.Operation_Name__c = o;
       update trackToUpdate;
       System.debug('Updated');
    }
    
     public static void TrackCreate(Decimal actual, Date d, ID i, ID o){
       Track_Indicator__c t = new Track_Indicator__c();
        t.Actual__c = actual;
        t.Date__c = d;
        t.Indicator_Id__c = i;
        t.Operation_Name__c = o;
        insert t;
    }
}


This is a trigger handler class
 
public class RecordTrackOnSongHelper {
    public static double getTotalSongWrintenByschool(Decimal month , ID operation)
    {
        return [SELECT Id FROM Song__c WHERE Month_Number__c = :month AND Operation_Name__c = :operation].size();
    }
    
    public static void recordTrack(List<Song__c> newRecords, String indicatorFullName, String projectName){
        
      
        if(indicatorFullName == '# of songs written by participating schools'
                                && projectName == 'Music Heals International')
        {
             //List<Track_Indicator__c> trackToInsertCaseStudy = new List<Track_Indicator__c>() ;
             //List<Track_Indicator__c> trackToUpdateCaseStudy = new List<Track_Indicator__c>() ;
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Song__c s : newRecords)
                 {
                         actual = (Decimal) getTotalSongWrintenByschool(s.Month_Number__c , s.Operation_Name__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, s.Month_Number__c, s.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked, actual, s.Date__c, Indicator[0].Id, s.Operation_Name__c);
                 }

             }
        }

    }
}

But see it for activities:
 
public class RecordTrackOnActivityHelper {
    
    public static double  getTotalActivityOn(Decimal month, ID operation, String activityType, ID projectId)
    {
          return [SELECT Id FROM Activity_1__c WHERE 
                                               Activity_Type__c = :activityType
                                               AND Project_Name__c =:projectId
                                               AND Month_Number__c =: month
                                               AND Operation_Name__c =: operation].size();
    }
    
    public static double getTotalCommunityMemberSensitized(Decimal month, ID operation, String activityType, ID project)
    {
        return double.valueOf([SELECT SUM(Number_Of_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = :activityType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : project
                                                     ANd Operation_Name__c =: operation][0].get('expr0'));
    }
    
    public static double getTotalTotalConertHeledBy(Decimal month, ID operation, String activityType, ID pr){
        return [SELECT Id FROM Activity_1__c WHERE Activity_Type__c =:activityType
                                             AND Month_Number__c = :month
                                             AND Project_Name__c = : pr
                                             AND Operation_Name__c =: operation
               ].size();
    }
    
    
    public static Double getTotalBoys(Decimal month, ID op, String actType, ID pr){
       return double.valueOf([SELECT SUM(Number_Of_Male_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = : actType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : pr
                                                     ANd Operation_Name__c =: op ][0].get('expr0'));
    }
    
    
    public static Double getTotalGirls(Decimal month, ID op, String actType, ID pr){
       return double.valueOf([SELECT SUM(Number_Of_Female_Participant__c) FROM Activity_1__c
                                                     WHERE Activity_Type__c = :actType
                                                     AND Month_Number__c =: month
                                                     AND Project_Name__c = : pr
                                                     ANd Operation_Name__c =: op ][0].get('expr0'));
    }
    
    
 
    public static void recordTrack(List<Activity_1__c> newRecords, String indicatorFullName, String projectName){
        
              
        if(indicatorFullName == 'Number  extracurricular activities'
                                && projectName == 'School Of Hope')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'Extra Curricula Activity'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
        
        if(indicatorFullName == 'Number of meetings with parents'
                                && projectName == 'School Of Hope')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'Meeting With Parent'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
      
        if(indicatorFullName == '# of hygiene club meeting carried out'
                                && projectName == 'WASH')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'hygiene club meeting carried out -(WASH)'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }

             }
        } 
        
        if(indicatorFullName == '# of sensitization campaigns carried out'
                                && projectName == 'WASH')
        {
             Indicator_1__c[] indicator = UtilitiesRecordTrack.getIndicator(indicatorFullName, projectName);
             if(indicator.size() > 0)
             {
                 Decimal actual;
                 for(Activity_1__c act : newRecords)
                 {
                     if(act.Activity_Type__c == 'sensitization campaigns'
                        && act.Project_Name__c == UtilitiesRecordTrack.getProjectID(projectName))
                     {
                         actual = (Decimal) getTotalActivityOn(act.Month_Number__c, act.Operation_Name__c, act.Activity_Type__c, indicator[0].Related_Project__c);
                         Track_Indicator__c[] tracked =  UtilitiesRecordTrack.getTrackIndicatorId(indicator[0].Id, act.Month_Number__c, act.Operation_Name__c);
                         UtilitiesRecordTrack.recordOrUpdate(tracked,  actual, act.End_At__c.date(), indicator[0].Id, act.Operation_Name__c);
                     }
                 }
                 
             }
        }
}

Trigger:
 
trigger RecordRelatedTrackIndicatorOnActivity on Activity_1__c (after insert, after update) {
    if(Trigger.isInsert)
    {
	  RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number of meetings with parents', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Numbers of  training sessions held', 'School Of Hope');
        
        
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of training session conducted for volunteers', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of people sensitized on the importance of after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of male adolescents attending training on sexual health and risk behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of female adolescents attending training on sexual health and risks behavior linked to their age', 'Comunity Development Campus'); 
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of youth participating in debate sessions', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in Koze Lakay', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in other community gatherings', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by adolescents', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by kids', 'Comunity Development Campus'); 
      
      
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number  extracurricular activities', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of hygiene club meeting carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of sensitization campaigns carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of parent meetings held on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of Delmas 32 community members sensitized on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band', 'Music Heals International');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band with special guest musicians', 'Music Heals International');
  

     
    }
 	
    if(Trigger.isUpdate)
    {
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number of meetings with parents', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Numbers of  training sessions held', 'School Of Hope');
        
        
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of training session conducted for volunteers', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of people sensitized on the importance of after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls participating in after-school activities', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of girls reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of boys reading at the library', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of male adolescents attending training on sexual health and risk behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of female adolescents attending training on sexual health and risks behavior linked to their age', 'Comunity Development Campus');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of youth participating in debate sessions', 'Comunity Development Campus'); 
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in Koze Lakay', 'Comunity Development Campus');  
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community leaders and members participating in other community gatherings', 'Comunity Development Campus');  
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by adolescents', 'Comunity Development Campus');   
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of community activities conducted by kids', 'Comunity Development Campus'); 
        
        
      
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, 'Number  extracurricular activities', 'School Of Hope');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of hygiene club meeting carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of sensitization campaigns carried out', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of parent meetings held on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of Delmas 32 community members sensitized on WASH issues', 'WASH');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band', 'Music Heals International');
      RecordTrackOnActivityHelper.recordTrack(Trigger.New, '# of concerts held by Little Kids Band with special guest musicians', 'Music Heals International');
    }
}

magine these functions being calling for every row in a CSV file or comming from mass update. even two rows, the governor limit exceipt raised.

If someone can help, I will realy appreciate that. I tried Map, but same reallity.
 
Attempting to track down an issue where I get "List has no rows...".
I've added some debug lines to my trigger and what's throwing me for a loop is the message is occuring within the trigger where there is no code and no calls to anything.
if(Trigger.isBefore && Trigger.isInsert){
System.debug('Case.Trigger.isBefore && Case.Trigger.isInsert');         
    }
    if(Trigger.isAfter && Trigger.isUpdate) {
System.debug('Case.Trigger.isAfter && Case.Trigger.isUpdate');
The debug line showing the isBefore && isInsert shows in the log, then the error, then the isAfter && isUpdate.

User-added image

Is there a way, without going through every trigger & class, to track where the issue is occurring?
I would like to understand how to add items to a wrapper, this doesn't compile.  I get Variable does not exist for each item in the list. I'm also at a loss for how to create an index that directly relates to the Case
 
public class TESTING {
    
    public class temptable{
        public Id cId{get;set;}
        public Case Case_obj{get;set;}    
        public Account Account_obj{get;set;}
        public Contact Contact_obj{get;set;}
        public string Email_DevName{get; set;}
    }
    
    public static void theCases(Case[] cs)  {
        
        List<temptable> temptable = new List<temptable>();
        
        String strTitle = '';
        String strReason = ''; 
        String strDetail = ''; 
        String strProduct = ''; 
        
        For (Case c:cs){
            temptable.cid = c.id;
            temptable.Case_obj = c;
            temptable.account_obj = c.Account;
            temptable.Contact_obj = c.Contact;
            
            if(c.Reason == 'Hot'){temptable[c].Email_DevName = 'Hot';}
            else if(c.Reason == 'Cold'){temptable[c].Email_DevName = 'Cold';}
            else {} // do nothing
        }
    }
}

 
Attempting to create a validation rule that insures the end user closing a Case has already entered a Comment on that Case but I can't seem to get the map to work correctly.  Here's what I have in the trigger; 
trigger Cases on Case (<etc>){

    if(Trigger.isBefore && Trigger.isUpdate){

             CloseValidation.CheckValidation(Trigger.new); 

    }
}
and here's the class; 
public class CloseValidation {
    public static void CheckValidation(Case[] cs) 
    {
        if(UserInfo.getProfileId()!='00e30000000d2ft'){ // bypass for Salesforce Administrator profile //
            map<Id, CaseComment> CaseCommentMap = new map<Id, CaseComment>();
            Id thisUser = UserInfo.getUserId();
            
            for (Case c:cs){
                if(c.Status=='Closed' && c.RecordTypeId=='01270000000Q9E1'){
                    CaseCommentMap.Put(c.id,null);
                }
            }
            CaseCommentMap.remove(null);
            CaseCommentMap.putAll([Select Id FROM CaseComment Where ParentId in : CaseCommentMap.keyset() AND CreatedById =:thisUser]);
            
            // if CaseCommentMap has a null for the CaseComment then error
            for(Case c:cs){
                if(!CaseCommentMap.containsKey(c.id) && c.Status=='Closed'){
                    // no key - fail
                    c.addError('You must have commented to close the case (CaseValidation.apx) ' + c.id );         
                } else {
                    // has key - pass
                }
            }      
        }
    }
}

What am I overlooking?
 

Hi,

 

I've created one child object called Rebate which has Master-Detail relationship with Account object. In my Batch Apex I'm trying to access related list of Rebate object on an Account object.

 

Here is my SOQL query:

Select (Select Id, Owner__c, Year__c From Account_Rebates__r) From Account a

 

When I'm running this query on salesforce.schema browser, I'm not getting any record but what I'm getting is red square.  I'm not sure what is going wrong on my end.

 

Can you please help me with this?

 

Thanks.