function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC LearningSFDC Learning 

need help in Test class in task trigger

for(Task tt :trigger.new)
{
    if(tt.whoId!=null  && tt.who.Name=='Lead'){
        lead=[select id,Fast_Phone__c from Lead where id =:tt.whoId ]; 

In test class when i am creating lead and insert it id into task . the if condition 'if(tt.whoId!=null  && tt.who.Name=='Lead')' is not matching. How to resolve this

Thanks in advance

 
Kevin CrossKevin Cross
Good morning!

Who.Name returns the name of the Contact or Lead.  I think you want Who.Type, which will return "Contact" or "Lead" based on which you associate.