Questions tagged [soql]

Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.

744 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
12
votes
0answers
212 views

Made 3500 SOQL Queries in one context. LIMITS HACK?

Steps to reproduce: Create Visualforce Email Template Create Visualforce component and add it into the email template Create Apex Controller for the component from pt.2 Do some SOQL queries there, ...
9
votes
2answers
294 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
1answer
2k views

Relationship query on Custom Metadata Type giving wrong results

I have a parent Metadata Type having a child relationship. SOQL behaves differently in each of the following scenarios: SELECT ALLFIELDS, (SELECT ALLFIELDS FROM Children__r ORDER BY Order__c) FROM ...
8
votes
1answer
437 views

SOQL Error Only When Accessing Lead.Address Standard Compound Address Field From WorkFlow Triggered Task Insert

I've added a section of code to our task trigger that retrieves two sets of address fields from the lead or contact the task is being made on - see below-. private static void ...
6
votes
0answers
41 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
0answers
79 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
2answers
432 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
1answer
411 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
0answers
1k 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
1answer
296 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
0answers
95 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
0answers
52 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
0answers
78 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
0answers
293 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
1answer
363 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,...
5
votes
2answers
1k views

Query Name on Contact if MiddleName is filled

I have a visual force page where I had to define a look up to Contact. So I used contact.ReportsToId like below <apex:outputLabel value="Select Requestor:" for="requestor"/> <apex:inputField ...
4
votes
0answers
53 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
1answer
54 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
0answers
78 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
0answers
44 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
0answers
71 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
1answer
337 views

SOQL Count() limits

Summer '18 changed Count() impact on query row limit from "number of records matched" to 1. Is there still some form of a limit, like selectivity criteria related limits, or can an arbitrary number ...
4
votes
0answers
228 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
0answers
115 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
1answer
385 views

Different result between a Salesforce Report and equivalent SOQL query

There is a report on Leads in my Salesforce instance which has a few filter criteria. The report is giving me 1716 lead records. Now I want to replicate the same logic in an SOQL and then fetch the ...
4
votes
0answers
671 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
1answer
987 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
0answers
103 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
0answers
136 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
0answers
1k 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
0answers
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
0answers
339 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
2answers
93 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
1answer
91 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
0answers
88 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
1answer
470 views

What Does Cardinality Mean in the Query Plan Tool?

I am running below query in query editor in the free developer edition SELECT count() FROM contact WHERE createdby.Name = 'gs650x' I am getting 17 records but when I click query plan tool I get ...
3
votes
0answers
118 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
1answer
665 views

Get Children Records out of Loops in Flows

Dear StackOverflowers, This is my first question on SO, so please bear with me if you find it naive. I have looked up and down the platform and surprisingly, I haven't been able to find a similar ...
3
votes
0answers
127 views

Filter Items for Approval by Object Type

I'm trying to query for Approval Items which are outstanding for the running user to approve, filtering these approvals by the object type they are related to. I've attempted to use the following ...
3
votes
1answer
85 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
0answers
72 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
1answer
268 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
0answers
1k 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 ...
3
votes
1answer
137 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 ...
3
votes
1answer
399 views

SOQL Error on Querying External Object?

I am trying a simple Query on an External Object and it is returning this error :- An error has occurred and you have been logged out: REQUEST_LIMIT_EXCEEDED: Your org exceeded one of the rate ...
3
votes
1answer
321 views

SFDX and Powershell script - querying knowledge article version returns SOQL malform error, but it runs fine in DEV Console

I am trying to download a specific knowledge article version (standard - not lightning) using SFDX and powershell. My query gets dynamically generated in the script... and the relevent line of the ...
3
votes
1answer
136 views

Is there a limit for number of content folders?

I am getting this error when I try to create a content folder using a visual force page(by inserting a record in contentfolder. As per this link, there should not be any limit for the number of ...
3
votes
0answers
3k views

EXCEEDED_ID_LIMIT: Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch

When I run following query in dataloader/workbench, I receive the below error. SELECT Count(Id) FROM Account where recordtype.name = 'Client' order by COUNT_DISTINCT(Id) EXCEEDED_ID_LIMIT: ...
3
votes
1answer
107 views

FOR VIEW SOQL for another user

Is it possible for me to use the FOR VIEW clause in SOQL for another user instead of the CurrentUser. For example I want to see how many records on the Case object a certain user has viewed in one day....
3
votes
1answer
52 views

SOQL Assistance Please

I am trying to run a SOQL query on my Account Object pulling data from a custom Object A that contains the Account name and it's Global Enterprise and Main HQ. It's a hierarchy of sorts. In a list ...

1
2 3 4 5
15