• satya G 4
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
update_c up=[SELECT Id,Name,updateopportunity__c,UpdatedAccountBy__c,updatecontact__c,updatecontact__r.Name,updatecontact__r.Email,updateBycontact__c,updateBycontact__r.Name,updateBycontact__r.Email,updatelead__r.Company,UpdateLeadBy__r.Name,UpdateLeadBy__r.Email,updatelead__c,UpdateLeadBy__c,updateAccount__c  FROM Update__c WHERE updateAccount__r.Id = :opp.AccountId AND (updateBycontact__r.Email!=null or UpdateLeadBy__r.Email!=null) ];
This is query in trigger so in test class,i insert a record on update_c like:Update__c  rf = new Update__c();
        rf.Name = 'TestReferral';
        rf.updateBycontact__c = con.Id;
        rf.UpdateLeadBy__c = ld.Id;
        rf.updatecontact__c = c.Id;
        rf.updatelead__c = l.Id;
        rf.updateAccount__c =opp.AccountId;
        //rf.updateAccount__c='00128000018abGD';
        rf.UpdatedAccountBy__c=opp.AccountId;
        
        insert rf;  
so,i need to satisfy the query in test class right..,wt should i do & how to get these values here
System.debug('>>>>>>>rf.updateAccount__c>>>>>>>'+rf.updateAccount__c);
        System.debug('>>>>>>>rf.updateBycontact__r.Email>>>>>>>'+rf.updateBycontact__r.Email);
        System.debug('>>>>>>>rf.updateAccount__r.id>>>>>>>'+rf.updateAccount__r.Id);
        System.debug('>>>>>>>rf.UpdateLeadBy__r.EMAIL>>>>>>>'+rf.UpdateLeadBy__r.Email);
        
while inert a update_c record,we can't get the parent record fields like above mails.so agian i queried on up_c objct,eventhough i didnt get:
rf=[Select id,Name,updateBycontact__c,UpdateLeadBy__c,updatecontact__c,updatelead__c,updateAccount__c,UpdatedAccountBy__c From Update__c  WHERE updateAccount__r.Id = :opp.AccountId AND (updateBycontact__r.Email!=null or UpdateLeadBy__r.Email!=null) ];
how to do.

Thanks & regards
i insert opportunity and related records between start and stop test:again i update the opp record eventhough the below code is not covered.

 if (trigger.isUpdate)
            {
                System.debug('>>>>>>>>>>trigger.old[i].StageName>>>>>>>>>>>'+trigger.old[i].StageName);
                if (trigger.old[i].StageName.equalsIgnoreCase('Awarded'))
                    alreadyInvited=true;
                
                if (trigger.old[i].Organization_Update_Received__c==true)
                    alreadyFormReceived=true;
            }

 
,here is my code :Integer parent= getParentId(s.Forum_Year__r.Year__c ,auth.getAccessToken(),auth);
                if (!(parent>0))
                    throw new WordpressException('Parent does not exist');
                
                obj.parent=parent ;
                if (!String.isEmpty(s.Session_Type__c)) {
                    Integer etype= lookupEvent(s.Session_Type__c,auth.getAccessToken(), auth);
                    List<Integer> evlst=new List<Integer>();
                    evlst.add(etype);
                    obj.event_type=evlst;
                }
i insert opportunity and related records between start and stop test:again i update the opp record eventhough the below code is not covered.

 if (trigger.isUpdate)
            {
                System.debug('>>>>>>>>>>trigger.old[i].StageName>>>>>>>>>>>'+trigger.old[i].StageName);
                if (trigger.old[i].StageName.equalsIgnoreCase('Awarded'))
                    alreadyInvited=true;
                
                if (trigger.old[i].Organization_Update_Received__c==true)
                    alreadyFormReceived=true;
            }

 
,here is my code :Integer parent= getParentId(s.Forum_Year__r.Year__c ,auth.getAccessToken(),auth);
                if (!(parent>0))
                    throw new WordpressException('Parent does not exist');
                
                obj.parent=parent ;
                if (!String.isEmpty(s.Session_Type__c)) {
                    Integer etype= lookupEvent(s.Session_Type__c,auth.getAccessToken(), auth);
                    List<Integer> evlst=new List<Integer>();
                    evlst.add(etype);
                    obj.event_type=evlst;
                }