We have email list builder in our Salesforce app. User specifies filter criteria for Contact sObject and builder generates SOQL query which then will be used to pull unique emails by external service via API. The need is to display number of unique emails in Salesforce UI before the user launches the Email Campaign through the external service.

有帮助吗?

解决方案

You can use the @ReadOnly annotation to increase the limit of queries. This is documented here - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_ReadOnly.htm. The down side of this is you can't carry out any DML operations and it must be used to annotate a Web Service or Schedulable implementation.

You can also use database.query(query) which creates the query at run time (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_System_Database_query.htm) like this (untested) :

AggregateResult results = database.query('SELECT COUNT(id) count FROM sObject');
Integer count = results.get('result');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top