如何使用 SOQL 从任务对象记录中获取电子邮件 [英] How to get Email from Task object record using SOQL

查看:48
本文介绍了如何使用 SOQL 从任务对象记录中获取电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 SOQL 从 Task 对象获取联系人/潜在客户电子邮件(我正在用 PHP 创建一个接口来备份具有特定主题的消息).这是我现在的查询:

I am trying to get the Contact/Lead email from the Task object using SOQL (I am creating an interface in PHP to back up messages with a specific subject). Here is my query right now:

SELECT Subject,Who.FirstName,Who.LastName,Who.Email,Who.Phone,Description FROM Task

这有效/不会抛出错误并给我结果,但是 Who.Email 总是空的(而且,巧合的是 Who.Phone 也是,但是这不是很重要).如果我尝试只使用 Email,我会收到一个错误,指出该字段不存在,这很奇怪,因为 Email 在作为标准字段的任务字段下.

This works/doesn't throw an error and gives me results, but Who.Email is always empty (and, coincidentally Who.Phone is as well, but it is not very important for this). If I try just using Email I get an error that the field doesn't exist, which is weird because Email is under Task Fields as a standard field.

我也尝试了几次谷歌搜索,但都没有找到任何帮助.

I have also tried several google searches with no sort of assistance found.

推荐答案

因为 Task 的 WhoId 和 WhatId 字段是多态的(即可以指向许多不同类型的对象),所以您不能像这样通过它们查询关系对于通常相关的对象.相反,您必须执行 2 个 SOQL 查询,第一个是获取任务信息,第二个是从 Who 指向的联系人或潜在客户获取信息.

Because the WhoId and WhatId fields of Task are polymorphic (i.e. can point to many different kinds of objects) you can't just query relationships through them like you can for normally-related objects. Instead, you'll have to do 2 SOQL queries, the first to get the Task information and the second to get the info from the Contact or Lead that the Who is pointing to.

这篇关于如何使用 SOQL 从任务对象记录中获取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆