检索SalesForce联系活动历史记录

时间:2016-11-02 01:10:04

标签: javascript salesforce soql

我正在使用JSForce库通过JavaScript与SalesForce进行交互,而且我遇到了一些我还没有弄清楚的问题。我的目标是为联系人提取最近的活动历史记录,以便我可以在第三方应用中显示他们的“操作”。我尝试过几种不同的方法...... 使用Chatter API,但这只返回应用程序中“Users”的数据,而不是实际的“contacts”(这是我想要的) 我还使用了许多variuos查询...例如

var query = "SELECT (SELECT ActivityDate, Description, WhoId, Subject, OwnerId from ActivityHistories) FROM AccountFeed WHERE ParentId = '" + id + "'";

var query = "SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, (SELECT ID, FieldName, OldValue, NewValue FROM FeedTrackedChanges ORDER BY ID DESC) FROM UserProfileFeed WITH UserId = '" + id + "' ORDER BY CreatedDate DESC, Id DESC LIMIT 20"

我们非常感谢您提供的任何指导! 谢谢!

1 个答案:

答案 0 :(得分:0)

您可以在StackExchange for SalesForce中找到有用的信息,以便检索ActivityHistory。但请注意,即使使用此链接,我也遇到了问题。

首先,您必须确定您要定位的系统中的用户帐户类型。在链接中,它是Account;对我来说,它是Contact

其次,系统可能对检索此类信息有一些限制和约束。以我的情况为例,有2个约束:

  • 限制为500(MALFORMED_QUERY: There is an implementation restriction on ActivityHistories. When you query this relationship, security evaluation is implemented for users who don't have administrator permissions, and you must specify a LIMIT with a maximum of 500

  • 需要特定过滤器(MALFORMED_QUERY: There is an implementation restriction on ActivityHistories. When you query this relationship, security evaluation is implemented for users who don't have administrator permissions, and you must use a specific sort order: ActivityDate DESC, LastModifiedDate DESC

最后,这是我的询问。

SELECT Name, (SELECT Subject,ActivityDate,ActivityType,ActivitySubtype,Description,Status FROM ActivityHistories ORDER BY ActivityDate DESC, LastModifiedDate DESC LIMIT 100) FROM Contact WHERE Id = 'abcde'