+ Start a Discussion
udayarangareddy mekalaudayarangareddy mekala 

trigger testclass

HI
  How to write the testclass for below triggercode
trigger jobname on job_c (Before Update, After insert,After update,Before delete) {
    list<Job_History_c> jb1 = new list<Job_History__c>();
    list<Job_Notes__c> jn = new list<Job_Notes__c>();
    list<User> listuser =[SELECT Name,Id FROM User];
    map<string,string> namevals = new  map<string,string>();
         for(User u : listuser){
              namevals.put(u.Id,u.Name);
         }
             for below if statement how to compare the oldvalue of the JOB_c to the new value of the JOB_c and how to    insert the job_History_c 
                if(newvals.Name!= oldvals.Name){
                    job_History__c jb = new job_History__c();
                         jb.Field__c = 'Name';
                         jb.New_Value__c= newvals.Name;
                         jb.Old_Value__c= oldvals.Name;
                         jb.jobId__c= newvals.id;
                         jb1.add(jb);
                         }
               insert jb1;        
                         }

Thanks in advance

 
Best Answer chosen by James Loghry
James LoghryJames Loghry
Hi,

It sounds like you're continuously looking for someone to write the code for any of your projects. These forums are not meant for that; you'll want to post over on the AppExchange site where you can match up with a developer looking to work on your project(s). 

https://appexchange.salesforce.com/developers