本文介绍了如何使用 Apex 在 SalesForce 中以编程方式访问报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 SalesForce 平台上编写一个应用程序,该应用程序可以从报告中提取联系人列表并将其发送到网络服务(比如向他们发送电子邮件或短信)

I'm trying to write an app on the SalesForce platform that can pull a list of contacts from a report and send them to a web service (say to send them an email or SMS)

我似乎找到的唯一方法是将报告结果添加到新创建的活动中,然后访问该活动.这似乎还有很长的路要走.

The only way I can seem to find to do this is to add the report results to a newly created campaign, and then access that campaign. This seems like the long way around.

我在网上阅读的每篇文章都说您无法通过 Apex 访问报告,但是这些文章的大部分或全部都是在上个月发布的 API 版本 20 之前编写的,该版本引入了一个新的报告对象.我现在可以以编程方式访问有关报告的信息(例如上次运行的日期等),但我似乎仍然无法找到访问该报告中包含的结果数据的方法.

Every post I read online says you can't access the reports through Apex, however most or all of these posts were written before Version 20 of the API was released last month, which introduced a new report object. I can now programmatically access info about a report (Such as the date last run etc) but I still can't seem to find a way to access the result data contained in that report.

有谁知道有没有办法做到这一点?

Does anyone know if there's a way to do that?

推荐答案

经过大量研究,我发现目前唯一的方法确实是抓取 CSV 文档.我猜康加等正在使用这种方法.

After much research into it, I've discovered the only way to do this at the moment is indeed to scrape the CSV document. I would guess that Conga etc are using exactly this method.

我们已经这样做了一段时间了,而且很有效.唯一的警告是:

We've been doing this for a while now, and it works. The only caveats are:

  • Salesforce 用户名/密码/安全令牌必须共享给应用程序连接.如果密码更改(默认情况下它已更改每 30 天左右)令牌也更改并且必须重新输入.

  • Salesforce username / password /security token has to be shared tothe app connecting. If the passwordchanges (and by default it is changedevery 30 days or so) the token alsochanges and must be re-entered.

您必须知道帐户的主机,这可能很难做对.例如,虽然大多数欧洲帐户会使用 emea.salesforce.com 来访问 CSV,但我们的帐户使用 na7(北美 7),即使我们位于爱尔兰.我目前正在将页面主机发送到应用程序并对其进行解析计算要使用的正确子域,但我认为必须有一个更好的方法来做到这一点.

You have to know the host of the account, which can be difficult toget right. For instance while most european accounts would use emea.salesforce.com to access CSV, our account uses na7 (North America 7) even though we're located inireland. I'm currently sending the page host to the app and parsing itto calculate the correct subdomain to use, but I think there has to be abetter way to do this.

Salesforce 确实需要通过提供 API 调用来解决这个问题,该调用允许动态导出自定义报告结果并允许我们使用 OAuth 连接到它.但当然,这不太可能发生.

Salesforce really needs to sort this out by supplying an API call which allows custom report results to be exported on the fly and allowing us to use OAuth to connect to it. But of course, this is unlikely to happen.

这篇关于如何使用 Apex 在 SalesForce 中以编程方式访问报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 20:57