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
1
vote
3 answers

Salesforce SOQL relationship query question

I want to get the field userhomepage from the custom table WebsiteUser via a SOQL query on the Account table. I tried about 10 different queries but i'm not getting it working... fe. I've tried SELECT field1, (SELECT userhomepage FROM User) FROM…
Bokw
  • 789
  • 1
  • 9
  • 21
1
vote
1 answer

Merge fields won't show on visualforce page

I just started learning Apex recently, and there's still a lot of topics that are hard for me to navigate at this time. I've searched everywhere for a solution that works, but I still haven't been able to figure it out. I've created a button on my…
Mykid
  • 13
  • 4
1
vote
1 answer

Is there a possible way to search the name of a lookup fields using the search.query using apex in salesforce?

I had a lookup field on my object and I want to search the name of the lookup using search.query in apex, how can I do this?. In my debug, I am returning nothing. Below is my sample code. String query = 'FIND \'Sonny McNeil\' IN ALL FIELDS RETURNING…
1
vote
1 answer

simple-salesforce bulk query takes hours for a simple soql

My bulk query has been taking hours in production today. Before this, it takes only a few minutes. Just wondering what might be the issue? This takes 2 hours (This is a test query on production) sf.bulk.__getattr__("Account").query("SELECT ID FROM…
Chad H.
  • 33
  • 1
  • 4
1
vote
1 answer

How to query a lookup on a lookup in salesforce SOQL

I have an record type of case which has a lookup to an Opportunity which has lookup to Account. When a query is run with workbench it works fine and I can get the account- however when its run in apex only the Opportunity ID is returned, not the…
Moriarty
  • 515
  • 3
  • 17
1
vote
1 answer

SOQL Subquery counting the number of results

I'm trying to create a SOQL query that pulls records from an Object based on if there are any results from another linked object. Here is sort of what I am trying to do. SELECT id, casenumber FROM case WHERE count(SELECT ContentDocumentId FROM…
Bryan Harrington
  • 991
  • 2
  • 17
  • 31
1
vote
1 answer

Let's say that there is an object called "Book" in Salesforce

The records in the book object are such, that one book can be the parent of other books, and it isn't necessary that each book has a parent book. Given ID of a book, how to find out whether that book has child elements or not using an SOQL query?
1
vote
2 answers

How to add auxiliary column inside query?

My table might look like this: | Email | ID | Order_date | Total | | ----------------- | --------- | ------------ | ------------ | |customerA@gmail.com| 1 | 01-01-2019 | 500 | |customerB@gmail.com| …
Amberjack
  • 45
  • 5
1
vote
1 answer

Populating an Apex Map from a SOQL query

// I have a custom metadata object named boatNames__mdt and I'm using two methods to get a list of picklist values in a String[]; First Method Map mapEd = boatNames__mdt.getAll(); string boatTypes = (string)…
1
vote
3 answers

Salesforce object describe has big data, how to get limited data like picklist values from salesforce object describe

I am looking for way to get fields and picklists for a salesforce object. I can do it with a REAT API call using /describe after the object name. But sometimes the returned JSON data is really big with 95% extra data I don't want, with repetitive…
Abraham
  • 12,140
  • 4
  • 56
  • 92
1
vote
2 answers

Need help in Dynamic SOQL

In my code i need to get the object name from the record id and based on the object name, i need to get the field name to add in my query. For now, I have hardcoded the field names, is there a better way to do this. The field in the where clause is…
Nandhini
  • 11
  • 2
1
vote
1 answer

Access a field from another table using the object relation

I am new to SalesForce and SOQL so sorry in advance if the question has already been answered, if yes link it to me. The aim of my SOQL query is to get all the contract information to generate PDF. There are tables: Contract, Contact and Account In…
Cobra
  • 200
  • 9
1
vote
1 answer

SOQL Query with a Subquery that uses GROUP BY and HAVING throws unknown error

I'm trying to query a list of records from a custom object (SB_User__c) where the value in the Email__c field is not unique. The following query captures the entire table as expected: SELECT Id, Name, Email__c, External_Id__c FROM SB_User__c ORDER…
1
vote
1 answer

SalesForce query returns results in Query Editor, but returns null from APEX code in Lightning component

I'm completely new to SalesForce and have inherited a report that's not working. Please excuse any incorrect terminology, since I'm learning about all this as I go. The report has three prompts: states, years, and members. All dropdowns are…
user3562286
  • 151
  • 2
  • 13
1
vote
2 answers

Salesforce, Apex, SOQL, SELECT with INCLUDES

What is wrong at this code in Apex? String states = 'California,New York'; List lstACC = [SELECT Id, Name, BillingState FROM Account WHERE BillingState INCLUDES (:states) LIMIT 10]; In Developer Console is an Error: "BillingState FROM…
Elo
  • 226
  • 5
  • 19