• rohi rohi
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hi,
I'm new to salesforce.
In trigger handler i need to check values based on contact id.

First i need to check the contact id in contacts object then take that contact id and check whether that id is exists in Request custom object along with other fields.If the second query returns empty then i need to add that contact id in Request object.

following is my code 

public static void createProces(List<Contact> oContacts)
 {
 List<Request__c> lsProcess_Request;
  Request__c  oRequest = new  Request__c(); 
 List<Request__c> uRequest = new List<Request__c>();

 for (Contact c : [SELECT Id, Email,Status__c  FROM Contact WHERE Id IN: oContacts] )
        {   
            //check whether active process or not
            lsProcess_Request =[SELECT Active__c ,Member__c,attempt_1__C,attempt_2__C,Attempt_1__c,Attempt___c FROM  Request__c WHERE
                               member__c =: c.Id and Active__c=true and (Attempt_1__c = true OR Attempt_2 __c = true )];
          if(lsProcess_Request == null)
{
               oRequest.Member__c = c.id;             
                oRequest.Attempt_1_Date__c = Date.today();
                oRequest.Attempt_2_Date__c = Date.today()+3;
               lwr.add(oRequest); 
}
           }
}

 Please advise me on this.
Hi,

My test class is not covering custom object fileds,see the below code.

in test class i am calling  a method  by passing list of ids,
RequestHandler.createProces(listof ids);

in actual class i'm validating contact ids and if that contact id is not there in another object i'm inserting that id along with other values,code is below:

 List<Request__c> lsRequest;
       Request__c oRequest = new Request__c();     
        List<Request__c> lWr = new List<Request__c>();
for(....)
{
 lsRequest =[SELECT Active__c ,Member__c,attempt_1__C,attempt_2__C,attempt_3__C FROM  Request__c WHERE
                               member__c =: c.Id and Active__c=true and (Attempt_1 __c = true OR Attempt_1 __c = true OR Attempt_1 __c = true)];
           
            oRequest =  (!lsRequest.isEmpty() && lsWaiver_Request.size()>0) ?lsWaiver_Request[0] : null;
          
      //if empty i'm inserting values 
            if(lsRequest.isEmpty())
            {   
              
              //test class is not covering these fields
                oRequest.Member__c = c.id;             
                oRequest.Attempt_1__c = true;
              //few other fileds
}
 
Thanks