+ Start a Discussion

Get Report Results with SOQL?

Hello- I'm new to Salesforce, an experienced developer otherwise.
I have been provided with a Salesforce account with a simple list of customers in it, and a report I'd like to get the contents of (built by someone else)

I now have Perl Salesforce::Simple working, connecting to the account, and listing some fundemental objects. ( I don't know what they mean yet!) I'd like to execute this report and recieve the result back.

The way Salesforce::Simple works is that it just wraps a SOQL query. Some type information is there, but I dont have to deal with it if I don't have to... Far, far simpler than the whole SOAP/WSDL model.

shortest route from A to B?

thanks in advance

it seems that the Salesforce world has some depth to it... I've run a sample using the non-Simple version, and the nesting of the SOAP return structures is really something.. Tools come in handy here, no doubt..

but back to the Report in question. It queries Accounts, using just four rules. (1 or 3) and (2 or 4). It selects most all fields from the Account, but no, not all.

I queried the Account object in Perl , but that is just the field names for an account object, not a way to get the Accounts themselves.

As far as the SOQL, I appreciate pointers on how to to begin the query. If I have to replicate the report using SOQL, then so be it. It really isn't that much.

thanks in advance

Perhaps you can describe what the report is supposed to do?  Its hard to know what kind of advice you want based on your previous post.  Do you want to know how the api works, or what specific queries to make?
>what is the report supposed to do?

yes, of course... the report generates a list of accounts fitting some criteria. The criteria are on simple fields, like ProgramType is X or ProgramType is Y.

the Accounts are names of business' (plural of business :-) with most all of the fields defined for them listed.. not quite every one though...

very SQL like. I am sure this can be done! I just a) can't find the report object, if that's usable, or b) dont know how to start the SOQL query on accounts..

I do have the apex_api manual open.. but where to start?

Gotcha.  So unfortunately the report object is not available (but it is one of the most requested objects).

So you'll have to reproduce the report through SOQL.

Look throught the SOQL documentation, for examples, but I imagine you'll want a query similar to

"select name, site from Account where ProgramType__c = 'foo'  "  or something similar, and where foo is constructed on the fly.

Here's a link to the SOQL section in the docs


> select xxx from Account where ...

its just called Account? hmmm
nothing to further specify?

> where ProgramType__c = 'foo'

  I see these __c things around here and there.. could someone say what that means?

> link

  yes, thanks, and I am looking there.. I needed to find out more about the nouns here, I suppose, before I can use the syntax well...

The __c simply denotes it as a custom field or object (vs a standard field/object)
Gareth DaviesGareth Davies
If you really, really, really must get access to the reports have a read of this:


(and look at the comments for some free example code).

aha, that article looks good. I will have at that shortly...

meanwhile, after looking at the Report definition (quite simple, fortunately, just a lot of custom field names), and using the excellent SoqlXplorer, I was able to craft a SOQL query that did what I needed it to..

So I got back the response as an array of named elements.. seems to work fine.. I can deal with it for now.

I am using WWW::Salesforce::Simple from CPAN in Perl.

Narbeh MovsesianNarbeh Movsesian
I am having a similar issue.

I am connected to the API, I am getting a token response, I want to query a report in which I have a list of my clients. This report lists my clients with their name, email, date_added , etc. I need to do something like Select name, email where date_added > Yesterday. and get a json response.

is this possible? if so how?