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
parkerAPTparkerAPT 

[BUG] Cannot access Title, Email or Phone fields on Task.Who or Event.Who (Unit Test included)

I've having trouble accessing the Title, Email and Phone fields when traversing the Who field on the task object.

The SOQL query is valid, but the returned fields for title, email and phone are consistently null.

 

I've included a unit test that illustrates this problem.

 

If this is indeed a bug, how do I go about filing a Ticket for this?

 

Thanks, 

Parker

 



// Test illustrating the inability to select the title, email or phone from the Who field on the Task object

// API Version: 15.0

static testMethod void testTitleInWhoTask(){
User oldOwner = [SELECT u.Id,u.name FROM User u WHERE u.isActive = true ORDER BY u.CreatedDate LIMIT 1];
String fakeTitle = 'SVP of Unit Testing';
Contact testContact = new Contact( firstName = 'Unit', LastName = 'Tester', email='unittest@example.com',title = fakeTitle,phone = '555-555-555');
insert testContact;
Task theTask = new Task(WhoId = testContact.id, subject = 'Unit Test Task', ActivityDate = System.Today() );
insert theTask;

// Validate that we have inserted the contact in properly
Contact cToTest = [SELECT c.id, c.firstname, c.lastName, c.name, c.email, c.title, c.phone FROM Contact c WHERE c.id = :testContact.id];
System.assertEquals(testContact.id, cToTest.id);
System.assertEquals(testContact.firstname, cToTest.firstname);
System.assertEquals(testContact.lastName, cToTest.lastName);
System.assertEquals(testContact.email, cToTest.email);
System.assertEquals(testContact.title, cToTest.title);
System.assertEquals(fakeTitle, cToTest.title);
System.assertEquals(testContact.phone, cToTest.phone);

// Validate that we can pull the title, email, name, phone etc from Who in Task
Task taskToTest = [Select t.Who.Title, t.Who.Email, t.Who.Name, t.who.Type, t.Who.phone, t.WhoId, t.id From Task t WHERE t.whoid = :testContact.id];
System.assertEquals(theTask.id, taskToTest.id);
System.assertEquals(cToTest.id, taskToTest.Whoid);
System.assertEquals(cToTest.Name, taskToTest.Who.Name);
System.assertEquals('Contact', taskToTest.Who.Type);

// None of these Pass. They all return null
System.assertEquals(cToTest.title, taskToTest.Who.Title);
System.assertEquals(cToTest.Email, taskToTest.Who.Email);
System.assertEquals(cToTest.phone, taskToTest.Who.phone);

}

 

VarunCVarunC

Not sure but I thought in documentation its mentioned that Name type fields Only return Name and Type values ... :smileyindifferent:

 

I also sometimes back hit with this issue that I was only able to return Name and Type values from Who object fields in activities .. but never thought it couod be a Bug ... I'm also now in queue for a solution to this issue now .. :)

parkerAPTparkerAPT

What's strange is that prior to Spring '09, the SOQL statement would not compile when I had tried to select Email from Who object fields.  It now compiles but returns null.

 

Looking in the Schema explorer via the eclipse IDE, on the Name object (the fields include: Email, Title and Phone).  I don't remember seeing these prior to Spring '09

 

 

Parker 

  

VarunCVarunC

hmm yes now I'm too kind of remembering this, earlier the Eclipse would not have build the SOQL, I've also been trying this somewhere around 3 months back, that is surely Winter 09 release .. good find ...

 

so anyone from SF or moderator please confirm, if we can fetch Titlle, Email, Phone etc fields from Name Type Field like WHO in Task/Event ? If yes then very sadly, it seems to be an Issue here since ONLY SOQL is builded properly without throwing error, but Data is NOT returned for these fields .... :(

parkerAPTparkerAPT

Any word from a SF developer / mod about this issue?

 

My specific use case involves displaying a list of Tasks in which I'd like to include the title of the contact to which the task is assigned.  Unfortunately, I cannot query Who.Title nor can I directly write Who.Title using an additional loop in which I query the Contact object directly.

 

Thoughts? 

NBlasgenNBlasgen

I find this silly too.

 

SELECT Id, Who.Id, (SELECT email FROM Lead) FROM Event WHERE ...

 

I can't even get it as a subquery which I guess is no surprised because it could be a Contact or a Lead. But in my case I know it's a Lead and I want to be able to force that.

nwingnwing

Yep,

for sake of discussion, I have a pre-assigned task that I want to delete when they perform that task......which is having its record created via the CTI plug-in......

 

So, when someone makes a call on a lead using the click-to-dial, I want it to query the task object, find the assigned task that represents the call they have just made, and then delete it......

 

BUT it is not finding anything, and driving me crazy......

 

Not sure what I am doing wrong.

NBlasgenNBlasgen

nwing,

 

API or some APEX?  You could look at ActivityHistories related to the object, find the task and erase it.  Or you could search for all Activies with a certian Who.Id and a Subject of whatever.  What you describe shouldn't be impossible.

nwingnwing

I am doing it with an apex trigger on the task object (before insert).  This is about the crankiest deploy I have every had.  I know the trigger is firing, not getting any errors or anything, but nothing is happening.

At this point it looks like it cannot be done with the CIT adapter creating the record.....If I go in and create the closed task manually, it performs as it should....but if I do it via the click-to-call, it doesn't seem to work.......

 

Not sure what is going on, but interesting in any case.....

 

 

nwingnwing

Another update........

 

It appears that I needed to have it perform on the 'isUpdate' instead of 'isInsert'.  I am guessing the CTI tool, which is a java plug in I believe, was creating the record and THEN updating it with the information I needed to filter for the delete of the completed 'task to be replaced'.    So it was working, but just didn't select any records to be deleted because the triggering record did not as of yet have the 'Who' relationship field populated/built on the insert.......

 

If anyone has any confirmation of this one way or the other it would be appreciated..........

 

Thanks,

rick@omnirick@omni

This bug is affecting our development too. Any news on the status? How can we escalate this and make it a priority. I can't imagine this being very difficult to fix for the SF developers.