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
charan@appscharan@apps 

getting values of contact to task

Guys,

 

 

I cannot get contact field from task object.

 

I am trying to get the phone number of contact from task.

 

 

i am using this code:

 

Task obj= new Task();

 

obj=[select id, subject, who.name from task];

 

 

I can get name  from contact to task, but I cannot get mobile phone form contact to task.

 

 

Please suggest me, how to retrieve mobilephone field on contact object to task.

 

Pradeep_NavatarPradeep_Navatar

Task Tobj = [Select Who.Phone, Who.Name, WhoId From Task limit 1];   // Who.Phone fetch the blank value even if data is there

 

Contact  Cobj = [Select Phone, Name From Contact where id=:obj.WhoId];   // So query this to get the phone value

               

The problem is with the relationship between objects. If we print the {!Tobj.Who.Phone} it always give the null value. So I think it is a schema level problem.