Questions tagged [soql]
Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.
879
questions with no upvoted or accepted answers
10
votes
1
answer
140
views
Why the Sorting Logic in Salesforce SOQL and UI is VERY different from other Systems?
The ordering mechanisms in Salesforce are really odd.
Take any SObject having any Text field (e.g. Name on Account) and create some Records. Do that on an Org with no other Records of the type (e.g. a ...
10
votes
2
answers
885
views
Field filter does not Work for Text Formula field used in SOQL
I have a simple SOQL query on Account which has a field Full_Address__c which is joint of Billing Street, City Zip.
When I use this field as a filter it doesn't return the records:
Example:
String ...
8
votes
1
answer
213
views
Query highest value of custom Field on Large Object
Existing Logic:
We have a trigger that gets the highest value of a custom Field "UIN__c" on various Objects and increments the value by 1 on each new Record. This Field functions as an ID ...
8
votes
0
answers
3k
views
getRecordTypeInfosByDeveloperName doesn't work with duplicate Developer names
Our product comes with a couple objects including RecordTypes.
In our customer org I'm adding some RecordTypes and experienced, that I can give them names that the packaged types already have.
So now ...
7
votes
0
answers
212
views
APEX Schema ChildRelationships: why have some relationships their relationshipName = null?
There is some strangeness in the some standard Childrelationships. Most Relationships are as expected, but let us take Account and Quote as an example:
On Quote we have a standard lookup field Quote....
7
votes
1
answer
645
views
Query to UserRecordAccess for multiple record ids returns unpredictable results
I am using the query editor.
Consider the following query:
SELECT RecordId, HasDeleteAccess FROM UserRecordAccess
WHERE UserId = '005J0000006QnWhIAK'
AND RecordId IN ('00UJ000000AZUulMAH','...
6
votes
0
answers
223
views
Contact MiddleName interferes with FirstName functions in full and partial sandboxes
We have Middle Name enabled in production. In a full sandbox, when we try any standard workflow, Flow Get Records step or SOQL query that involves Contact.FirstName = 'some value', the query/function ...
6
votes
0
answers
323
views
SOQL Aggregate functions circumventing limits?
We're working in a managed package that leverages SOQL aggregate functions and we want to ensure we are considering governor limits appropriately. To prepare for it we have created a Scratch Org with ...
6
votes
2
answers
1k
views
SOQL with ORDER BY and NULLS LAST ASC return wrong order results when we order by field from relationship
I noticed that SOQL with ORDER BY and NULLS LAST ASC returns results in wrong order (especially when I order by field from relationship). I wonder if it is some kind of bug or I've done some mistake ...
6
votes
1
answer
729
views
Unable to query with cross-Object pick-list field filter on Custom Metadata SOQL
I came across something weird, SOQL which has a filter as cross-Object picklist field doesn't return rows, even if records exist.
Minimum viable code to replicate:
Create a new custom metadata type, ...
6
votes
0
answers
3k
views
Why does SOQl query for Owner.UserRole.Name on Opportunity cause error in Opportunity Territory Assignment apex class
I've been working on an Apex class to do our Opportunity territory assignments based on the example here. I needed to modify it to support our rules that included checking the User Role on the ...
6
votes
0
answers
206
views
What's happening upon deletion of a Group record
I just ran a few consecutive tests of inserting and deleting a bunch of groups via the developer console (execute anonymous).
Inserted 50 Group records:
List <Group> groups = new List <...
5
votes
0
answers
93
views
Error when using FIELDS(STANDARD) in an Apex SOQL query : System.QueryException: No such column 'EffectiveDate' on entity 'Quote'
I recently implemented the new FIELDS(STANDARD) functionality in Apex queries and I am using the following query now:
SELECT FIELDS(STANDARD), Custom1__c, ... , CustomN__c
FROM Quote
WHERE Id =: ...
5
votes
1
answer
186
views
Discrepancies between downloaded Setup Audit Trail and SetupAuditTrail query
I have noticed that delegated user logins (i.e. when a managed package admin logs in via grant login access) show up in the downloaded setup audit trail, but do not show up in a SOQL query of the ...
5
votes
0
answers
86
views
Using Salesforce indexes
I'm working on an org that will have around 25m opportunities when data migration is complete. I'm trying to anticipate the issues we will face running batch processes against this data volume. We ...
5
votes
0
answers
500
views
Working with Very Large SOQL Queries
Background
This is a question about your experiences managing huge amount of data for UIs.
With an ERD like this, where the arrow directions reflect the fields lookup directions. (e.g. entity "B" ...
5
votes
1
answer
500
views
SOQL error with relationship
I have one query as below:
select id,functional_system_user__c,
Test_Created_Date__c,
Test_Login_Date__c,lastmodifieddate,name,
isactive,Reactivation_Date__c,email,...
4
votes
0
answers
435
views
System.UnexpectedException: common.exception.SfdcSqlException: ERROR: portal "C_6031" does not exist
Since the Summer 22' release these uncatchable UnexpectedException errors have been popping up sporadically on code that hasn't changed in multiple orgs we manage.
The stacktraces always originate ...
4
votes
0
answers
63
views
ContentVersion queries omitting recent records unless queried by an ID field
We are seeing a very strange behavior in a Summer '21 sandbox. Queries for ContentVersion will not return "recently" created records, unless queried by an ID or relationship. For example:
...
4
votes
2
answers
403
views
How to replicate the functionality of delivered "File Engagement" lwc card?
In our org we have a need to programmatically replicate the functionality of delivered “File Engagement” component/card.
Here is a snapshot from our live org, on a ContentDocument view page:
Since ...
4
votes
0
answers
74
views
Is this a good Model for "Guaranteeing" Record Updates Don't Fail due to ROW_LOCK/Race Conditions?
Background: The zqu__Quote__c object in our org has two child objects from another managed package we use for eSignature and credit card capture. One of those two child objects collects the Credit ...
4
votes
1
answer
364
views
Find distinct accounts and fetch their respective record ids?
I'm trying to fetch person account records that are unique and I'm trying an aggregate query as such:
SELECT count(Id), FirstName, LastName, PersonEmail FROM Account
WHERE IsPersonAccount = true
...
4
votes
0
answers
166
views
SOQL query: "sObject type 'FeedPollChoice' is not supported" for specific user
I have an application that is making calls against the REST /services/data/<api version>/query/ endpoint. My Salesforce org has two users: Alice has the "System Administrator" profile, and Bob ...
4
votes
0
answers
53
views
Should I be concerned about thousands of write operations per minute?
I am setting up a POC which would create a junction between User and Case (using Lookup relationships only). We would have 10k+ users each touching several records per hour, so we might expect this ...
4
votes
0
answers
86
views
SOQL query results differ on selecting from varying columns
I'm querying on Contact object where the results are varying on Bulk API vs querying on developer console.
Total records on Contact is 997820.
Query on developer console:
select count(id) from ...
4
votes
0
answers
602
views
Deleted contact's ID is not removed from converted lead. Why?
We have a requirement to delete all converted leads whose corresponding contacts have been deleted. Upon implementation we noticed something odd:
After creating and converting a lead via UI (classic ...
4
votes
0
answers
154
views
Salesforce big objects pagination
Given that SOQL for big objects doesn't support OFFSET, how should pagination be implemented for big objects?
4
votes
0
answers
1k
views
USING SCOPE Everything not working
I wrote a trigger on ContentDocumentlink to get a count of number of files uploaded against Service_Request__c (Custom Object) record.It works fine for new files are uploaded on Service Request record....
4
votes
1
answer
2k
views
Easiest way to delete a million records?
Been doing tests in sandbox in which I've created about a million accountshares that I need to get rid of for testing.
I'm trying data loader in bulk api mode to export than delete but I keep ...
4
votes
0
answers
113
views
Is This Project Possible?
I'm setting up a Wordpress site for a new customer. They have moved their customer database from a plesk environment to a salesforce database, 13 records per row including address, id, phone number, ...
4
votes
0
answers
142
views
Trigger Design Question
A bit of context:
Our company sells vacation rentals and has over 60 properties. When a customer chooses a property, it is stored in a look-up field called Lead.Property__c. They will also choose ...
4
votes
0
answers
2k
views
how to read all Content Notes saved as 'SNote' (Beta New Notes feature) for a Parent record all users?
I have been trying to read all New Notes (richtext version) via SOQL query in Apex Controller class.
The design specifications for new notes signifies that they are stored in as ContentVersion ...
4
votes
0
answers
610
views
Query Opportunity Partner Name
I am trying to write a SOQL query that pulls info from opportunities, and I need to pull out the name of the primary partner accout(if there is one). This isn't for a trigger, but for a nightly data ...
4
votes
1
answer
2k
views
Is there a simple way to generate a create table script from a salesforce class?
I am looking for a way to synchronize Salesforce data with a local database. At the moment I just want a pain free way of downloading the data. I've been playing around with importing CSVs from the ...
4
votes
0
answers
458
views
Loading Tasks using REST API returns no result, but second try returns a page of Tasks
Sometimes I experience weird issue when loading Tasks over REST API using simple SELECT Id, ... FROM Task SOQL query take quite some time and then returns with nothing, but on the second try it ...
4
votes
1
answer
183
views
Subqueries in soql for loop vs standard soql queries
I have 26 accounts and 24 contact records in the org and running a SOQL query on them (fetching Accounts along with contacts). Found that if SOQL for loop is used then the child records fetched in the ...
4
votes
2
answers
102
views
System.NullPointerException: Attempt to de-reference a null object Error
Method : This just one method of the class I am testing from Dev console
public Employee__c getEmployeeDetails()
{
Employee__c emp = null;
emp = [SELECT field1__c, field2__c, field3__c FROM ...
4
votes
1
answer
98
views
SOQL not returning row (when it should be)
Running into a very weird issue that is actually causing preventing my IDE from compiling (mavensmate)...
When Mavensmate compiles, it first checks the server version of the file to make sure it can ...
3
votes
1
answer
73
views
Is the User Mode approach to object and field security acceptable in a security review?
This Enforce User Mode for Database Operations looks by far the cleanest approach to implement the object and field-level security that is required to pass a Salesforce AppExchange Security Review.
(...
3
votes
1
answer
102
views
Why does this query exclude records if the field order is changed
I have code that works on a scratch org but isn't working in production. I've tracked it down to a query that's searching a table. The Apex code looks like this:
SELECT Id
FROM Tag__c
WHERE Name IN :...
3
votes
0
answers
243
views
ContentDocumentLink SOQL doesn't return all rows
I have the same question as this one (but couldn't comment on it)
To reproduce the issue:
Map<Id, Contract> limitedContracts = new Map<Id, Contract>([
SELECT Id
FROM Contract
...
3
votes
0
answers
92
views
Why is my Salesforce-SOQL-Subquery-Query discarding entrie
UPDATE
It seems that this issue only occures if the for-each-loop handles more than one entry. If the SELECT-Statement just handles one Near_By_Metadata__mdt, everything works fine and i get all ...
3
votes
0
answers
520
views
Reliable Salesforce JDBC to be used with DataGrip
Do you recommend any particular JDBC for Salesforce (can be paid) which is reliable enough to be used for commercial purposes along with DataGrip (or similar) software?
I've been checking similar ...
3
votes
0
answers
355
views
SOQL query in Trigger returns no results but returns a row in Developer Console
I have the following code snippet in a Helper class that's being called by an After Insert trigger (modified to demonstrate my objective):
Set<Id> reuseIds = new Set<Id>();
reuseIds.add('...
3
votes
0
answers
30
views
Any way to re-enable first time login screen?
Doing some automation testing, and wondering if there is any way to re-enable the screen that shows up the first time a user logs into a sandbox asking you to register your phone number or click 'I ...
3
votes
1
answer
205
views
selectivity threshold + OR condition in where clause
I'm facing trouble in understanding salesforce documentation, about selectivity threshold if SOQL uses two fields in where clause with 'OR' Condition. For e.g.
Select id from account where FieldA = ...
3
votes
0
answers
80
views
Strange SOQL Query result
So i used two queries one after another in same org:
Q1:
SELECT Id,Name, Project__c, Activity__c, AMS_Solutions_c__c
FROM Design_Time_Sheet__c
WHERE Project__c = null OR Activity__c = null
ORDER BY ...
3
votes
1
answer
570
views
Cannot ORDER BY when querying Custom Metadata
I have Custom Metadata types with simple relationships between them. When I query them with a relationship query and try to ORDER BY, only 1 of the inner records is returned.
I run this in Anonymous ...
3
votes
0
answers
936
views
SOQL "All Rows" on Bulk API alternative
I am required to retrieve all the records (including archived and deleted records) from a Salesforce object. I understand that this can be achieved using queryAll(). However, I have an environment ...
3
votes
1
answer
327
views
Querying Opportunities related to a contact return only Open Opportunities
I am doing subquery Of Opportunities on Contact as follows:-
Select id,(select id from Opportunities) from Contact where id in (select ContactId from OpportunityContactRole)
I know this will return ...