Questions tagged [soql]

SOQL is the Salesforce Object Query Language.

SOQL, the Salesforce Object Query Language is a SQL like syntax used on the force.com platform to query records within a Salesforce instance. It can be used in triggers, or fully fledged Apex code, or via their web services API.

748 questions
17
votes
6 answers

salesforce SOQL : query to fetch all the fields on the entity

I was going through the SOQL documentation , but couldn't find query to fetch all the field data of an entity say , Account , like select * from Account [ SQL syntax ] Is there a syntax like the above in SOQL to fetch all the data of account ,…
Sukhhhh
  • 1,009
  • 2
  • 13
  • 19
16
votes
4 answers

Salesforce SOQL describe table

Is there a way to fetch a list of all fields in a table in Salesforce? DESCRIBE myTable doesn't work, and SELECT * FROM myTable doesn't work.
Maverick
  • 3,039
  • 6
  • 26
  • 35
12
votes
1 answer

Checking for Blank Date field in Salesforce

How do I check if a field is Blank in Salesforce using SOQL. Thanks
Kunal Deo
  • 2,248
  • 2
  • 18
  • 27
11
votes
1 answer

SOQL Type conversion (SalesForce.com)

The problem is that I need to compare two fields of different types in a SOQL query. TextField is a Picklist (so really text) and IntField is a Number(2, 0). Changing the types of these fields is not possible. I would like to write SOQL…
Christoph
  • 4,251
  • 3
  • 24
  • 38
11
votes
3 answers

Python Simple Salesforce Select All Fields

I'm using Python Simple-Salesforce to query data via SOQL. I know that "SELECT *" is not supported in SOQL syntax, so I want to create a Python script to gather a string list of all fields to insert into the SELECT statement. Below is how I am…
mwhee
  • 652
  • 2
  • 6
  • 17
11
votes
4 answers

How to add comments in SOQL

Is it possible to put comments in SOQL? The Force.com explorer doesn't support basic operations like undo/redo and I can't find any way to enter comments so experimenting with queries is painful. I've tried all the usual suspects --, #, /*, //
mattmanser
  • 5,719
  • 3
  • 38
  • 50
10
votes
2 answers

How to perform a JOIN in Salesforce (SOQL) - Simple Salesforce (Python Library)

I am using simpleSalesforce library for python to query SalesForce. I am looking at two different object in SalesForce: Account and Opportunity (parent-child). There is an accountId inside the opportunity object. I am trying to perform an inner join…
Dominik Sajovic
  • 603
  • 1
  • 8
  • 16
9
votes
1 answer

SOQL query with subquery

I'm having trouble getting the results I want from a Salesforce/Apex/SOQL query. I want: A list of Contact objects containing only contacts who are CampaignMembers of a set of campaigns; and they should have the data from that Campaign member easily…
Benj
  • 1,853
  • 4
  • 18
  • 27
9
votes
3 answers

I am receiving the error "Bind variables only allowed in Apex Code [MALFORMED QUERY]" when testing a SOQL statement called from Jitterbit

We are using Jitterbit to query records from Salesforce, but we are running into an issue. In the query condition statement I am comparing two fields from the Salesforce table. When I go to test the query, it gives me the error "Bind variables only…
NickFranco
  • 91
  • 1
  • 1
  • 2
8
votes
4 answers

Ordering and Limiting A Subquery In Salesforce SOQL

I am attempting to retrieve the owner of a case, based on a partial match, where we choose the most recent case that matches the partial match. This is the query I am attempting: SELECT User.CustomField__c FROM User WHERE User.Id IN ( SELECT…
Fenton
  • 241,084
  • 71
  • 387
  • 401
8
votes
7 answers

SOQL query WHERE Date = 30_days_ago?

How do I make a SOQL query like this? SELECT id FROM Account WHERE LastActivityDate = 30_DAYS_AGO This produces an error: MALFORMED_QUERY: Account WHERE LastActivityDate = 30_DAYS_AGO ^
Dave S
  • 599
  • 2
  • 8
  • 17
7
votes
1 answer

After Update Trigger pending Approval request OriginalActorId

The trigger below is built to pull the most recent "assigned to" user (or OriginalActorId) from the approval process list, the Approval_started__c field is checked as an initial submission action from a specific approval process. The issue I have is…
Sam
  • 487
  • 4
  • 12
  • 31
7
votes
3 answers

Salesforce equivalent of "SELECT DISTINCT"?

I want to know what all the existing values of a field are. In SQL that would be something like: SELECT DISTINCT foo FROM bar How might I do this with salesforce's SOQL?
John Mee
  • 50,179
  • 34
  • 152
  • 186
7
votes
2 answers

SOQL issue when querying ActivityHi​story as a subquery..​

I'm querying ActivityHistory, and it seems that you can only query it as the object of a SUBQUERY against some other object. That's fine - I changed my query to query against the Account object, with ActivityHistory in a subquery. Seemed to work…
loneboat
  • 2,845
  • 5
  • 28
  • 40
6
votes
1 answer

Soql query to retrieve opportunities between two dates

I am trying to retrieve opportunities created between 01-01-2011 and 06-30-2011. Select o.CreatedDate, o.Id, o.LastModifiedDate from Opportunity o where o.CreatedDate > '1/1/2011' and o.CreatedDate < '12/31/2011' order by …
Prady
  • 10,978
  • 39
  • 124
  • 176
1
2 3
49 50