• sk aleem
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 1
    Replies
scenario: in an object there are two fields called field1 and field2 and i have 100000 records,out of 70000 record values are equal in field1 and field2.now dispaly those 70000 records on visualforce page.
Thanks Mahesh D but i got error
in Meeting__c object i create a validation rule if Purpose__c is picklist field is 'New Business' or 'Modification' then Outcome__c field (currency) and Expected_Closed_Date__c field(Date) should not blank

test cllass
@istest
public class meetingOverviewFormControllerTest {
   static testMethod void testMethod1(){        
    Account acc=new Account(Name='TestMethod');
     insert acc;
     Opportunity opp=new Opportunity(Name='TestOpp',StageName='Closed Won',CloseDate=system.today());
    insert opp;
       Meeting__c mRec = new Meeting__c(Purpose__c = 'New Business',Outcome__c = 20000,Expected_Closed_Date__c = system.today(), Outcome_Flag__c = true,Opportunity__c = opp.Id,Account__c = acc.Id );
     insert mRec ;
      
       system.debug('meeting rec----->'+mRec);
    Test.StartTest();
          ApexPages.StandardController sc = new ApexPages.StandardController(acc);

            meetingOverviewFormController testAccPlan = new meetingOverviewFormController(sc);

            PageReference pageRef = Page.MeetingOverviewForm;
            pageRef.getParameters().put('id', String.valueOf(acc.Id));

            Test.setCurrentPage(pageRef);

            testAccPlan.FeedbackRadio=true;

            testAccPlan.submit();

       Test.StopTest();

    }

}

error:

rt failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Outcome and Expected Closed Date fields should not blank if the Purpose values New Business or Modification: []

 
Extension controller class:
public class meetingOverviewFormController {
    public final Account accountRec;
  
    public Boolean FeedbackRadio{get;set;}
    public List<Meeting__c> meetingRecList{get;set;}
    public meetingOverviewFormController(ApexPages.StandardController controller){
        accountRec=(Account)controller.getRecord();
        meetingRecList=[SELECT Id,Name,Start_Date__c,End_Date__c,Location__c,Outcome__c,Expected_Closed_Date__c,Purpose__c FROM Meeting__c WHERE Account__c=:accountRec.Id];
    }
    public PageReference submit(){
         Task T = new Task();
          Case c = new  Case();
          system.debug('Feedback radio value-->'+ FeedbackRadio);
        if(FeedbackRadio == true){
            system.debug('yesstruee');
            T.Type = 'Email';
            T.Description = 'Reassign the outcome'; 
            T.Subject='Outcome monitoring';
            T.WhatId = accountRec.Id;
            //c.ContactId = conID;
            c.AccountId = accountRec.Id;
            system.debug('Case Record Id--->'+ c.Account);
            system.debug('Account record Id-->'+accountRec.Id);
            c.Status = 'New';
            c.Priority='Low';
            c.Origin = 'Phone';
     }
       insert T;
       insert c;
            System.debug('task reult'+t.Id);
         System.debug('case reult'+c.Id);
            PageReference page = new PageReference('/'+accountRec.Id);
        page.setRedirect(true);
        return page;
 }
}
hi   can anybody help me to write Test class for this Trigger  and trigger handler class (after update)
custom object(Meeting__c in this checkbox field defult checked) 
scenario:if opportunity stage is 'closed own' or 'closed lost' then meeting__object check box is unchecked

opportunityTrigger
trigger opportunityFactoryTrigger on Opportunity (after update) {
  opportunityFactoryTriggerHandler.doAfterUpdate(trigger.new,trigger.newMap);
    
}

opportunityFactoryTriggerHandler​
public  class opportunityFactoryTriggerHandler {
     public static void doAfterUpdate(List<Opportunity> oppRecList, Map<Id, Opportunity> newMap){
      List<Meeting__c> mettingRecList1 = new List<Meeting__c>();
      List<Meeting__c> meetingRecListToBeUpdated = new List<Meeting__c>();
      mettingRecList1 = [SELECT Id, Opportunity__c FROM Meeting__c WHERE Opportunity__c IN :newMap.keySet()];
        for(Opportunity oppRec : oppRecList){
               if(oppRec.StageName == 'Closed Won' || oppRec.StageName == 'Closed Lost' ) {
                    for(Meeting__c meetingRec : mettingRecList1) {
                        if(meetingRec.Opportunity__c == oppRec.Id) {
                          meetingRec.Outcome_Flag__c = false;
                          meetingRecListToBeUpdated.add(meetingRec);
                        }    
                        
                    }
                    
                } 
         } 
          update meetingRecListToBeUpdated; 
    }     

}
hi   can anybody help me to write Test class for this Trigger  and trigger handler class (after update)
custom object(Meeting__c in this checkbox field defult checked) 
scenario:if opportunity stage is 'closed own' or 'closed lost' then meeting__object check box is unchecked

opportunityTrigger
trigger opportunityFactoryTrigger on Opportunity (after update) {
  opportunityFactoryTriggerHandler.doAfterUpdate(trigger.new,trigger.newMap);
    
}

opportunityFactoryTriggerHandler​
public  class opportunityFactoryTriggerHandler {
     public static void doAfterUpdate(List<Opportunity> oppRecList, Map<Id, Opportunity> newMap){
      List<Meeting__c> mettingRecList1 = new List<Meeting__c>();
      List<Meeting__c> meetingRecListToBeUpdated = new List<Meeting__c>();
      mettingRecList1 = [SELECT Id, Opportunity__c FROM Meeting__c WHERE Opportunity__c IN :newMap.keySet()];
        for(Opportunity oppRec : oppRecList){
               if(oppRec.StageName == 'Closed Won' || oppRec.StageName == 'Closed Lost' ) {
                    for(Meeting__c meetingRec : mettingRecList1) {
                        if(meetingRec.Opportunity__c == oppRec.Id) {
                          meetingRec.Outcome_Flag__c = false;
                          meetingRecListToBeUpdated.add(meetingRec);
                        }    
                        
                    }
                    
                } 
         } 
          update meetingRecListToBeUpdated; 
    }     

}
Extension controller class:
public class meetingOverviewFormController {
    public final Account accountRec;
  
    public Boolean FeedbackRadio{get;set;}
    public List<Meeting__c> meetingRecList{get;set;}
    public meetingOverviewFormController(ApexPages.StandardController controller){
        accountRec=(Account)controller.getRecord();
        meetingRecList=[SELECT Id,Name,Start_Date__c,End_Date__c,Location__c,Outcome__c,Expected_Closed_Date__c,Purpose__c FROM Meeting__c WHERE Account__c=:accountRec.Id];
    }
    public PageReference submit(){
         Task T = new Task();
          Case c = new  Case();
          system.debug('Feedback radio value-->'+ FeedbackRadio);
        if(FeedbackRadio == true){
            system.debug('yesstruee');
            T.Type = 'Email';
            T.Description = 'Reassign the outcome'; 
            T.Subject='Outcome monitoring';
            T.WhatId = accountRec.Id;
            //c.ContactId = conID;
            c.AccountId = accountRec.Id;
            system.debug('Case Record Id--->'+ c.Account);
            system.debug('Account record Id-->'+accountRec.Id);
            c.Status = 'New';
            c.Priority='Low';
            c.Origin = 'Phone';
     }
       insert T;
       insert c;
            System.debug('task reult'+t.Id);
         System.debug('case reult'+c.Id);
            PageReference page = new PageReference('/'+accountRec.Id);
        page.setRedirect(true);
        return page;
 }
}