Skip to main content

Questions tagged [soql]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
407 views

SOQL query to query from child to parent and then to another child

I am checking if it is possible to construct a SOQL query using the below object structure. I am using the out of the box WorkOrder object to query Account fields from the Account object. I have a ...
sumchans's user avatar
  • 789
0 votes
1 answer
45 views

Too many soql rows :101 for SOQL query on user object

I have an issue on running some functionality from the front end. while executing the user query, the system gives an error message Too Many SOQL rows:101. I have checked the code, it is not inside ...
SFDC LWC's user avatar
0 votes
2 answers
638 views

Not getting any records from ContentVersion in Salesforce SOQ query which we are not owner of

When I am creating a new record (release), I would like to get a file off a related record (inventory) and then create a copy of it on the release. The problem I am facing, is that this only works if ...
Finbar Tracey's user avatar
1 vote
1 answer
89 views

How to storage data in Apex Controller for server side caching?

Let's say I have the following method getMyString() in my Apex Controller. I would like to refresh this SOQL query once in 30 minutes. Would it be possible to store the data in a 'local storage' type ...
Z0q's user avatar
  • 91
8 votes
3 answers
459 views

Automated Process User and AccessLevel.UserMode - Should It Lose Access?

Has anyone tried using the new user-level access DML operations with the automated process user, say in a platform event trigger? It seems as though calling Database.insert(records, AccessLevel....
Matt Lacey's user avatar
  • 25.7k
2 votes
1 answer
144 views

SOQL : View details of CronTrigger.CronJobDetail.Name

I am trying to run this query to get the details of the Apex class for scheduled jobs. SELECT ApexClassId,Id,JobItemsProcessed,JobType,Status,NumberOfErrors,MethodName,CronTrigger.CronJobDetail.Name ...
Endless's user avatar
  • 95
0 votes
1 answer
84 views

Correlated Not In Subquery

Because there is no ability to create a trigger to detect changes to case team members, we end up with situations where tasks assigned to a case team member are "orphaned" when a case team ...
user1821431's user avatar
2 votes
1 answer
135 views

SOQL Lib how to test a sub query

I am trying to test a sub query using SOQL Lib In the docs it says will ignore all filters and relations so how is this possible if I cannot create a relationship? My example is to get all ...
Default 's user avatar
-2 votes
1 answer
345 views

Getting Distinct Values in SOQL Query

I need to provide a query that gives me the latest StageName from the Opportunity object sofar I have tried this by writing a query for OpportunityHistory and the OpportunityFieldHistory. The thing is ...
Will Kreuger's user avatar
9 votes
2 answers
969 views

Executing SOQL with User Mode and then DML with user Mode causing Exception

I couldn't find if SOQL and DML become interlinked when using WITH USER_MODE with SOQL and DML both in single transaction. I've below sample code to be triggered on a button from an LWC: @AuraEnabled ...
VarunC's user avatar
  • 6,000
0 votes
1 answer
337 views

How to deactivate all flows via sf cli

I'm trying to deactivate all active flows via sf data cli I saw docs said we can deactivate if via Metadata field You can activate and deactivate flows with the Metadata field. Below command is ...
vctqs1's user avatar
  • 95
0 votes
0 answers
33 views

Non-required lookup + lookup formula WHERE condition = weird results?

Lets assume sObject_A with a formula field that calculates some positive number based on record fields. If the number cannot be calculated due to lack of data, the number is set to -1. sObject_B has ...
Kacper A's user avatar
0 votes
2 answers
107 views

Using SOQL to pull records where conditions can be AND but also OR

I have a scenario where we need to look at records where at least one of two conditions must be met, but we also need to include where both conditions are met. Here is the query: SELECT Name, ID, ...
S D's user avatar
  • 1
0 votes
1 answer
34 views

SOQL Count Distinct Accounts based on MIN Approved Date

I am trying to create a SOQL query to give me a monthly count of participants based upon the Accounts initial/min approve date. Here is what I have so far which gives me the correct count by program ...
Nate23VT's user avatar
  • 103
0 votes
0 answers
118 views

Facing issue to access salesforce files as community user customer

I am facing an issue with the community portal user to access salesforce files. I created a library and assigned it to a public group. But when I logged in as experience user, it is not showing that ...
Hritik Thakur's user avatar
2 votes
1 answer
251 views

SOQL from Apex class - Internal server error

I'm trying to get the AccountId of the Opportunity. I use recordId (opportunity ID) to pass to my Apex method. But I am getting this weird error: Error: An internal server error has occurred Error ID: ...
dan-klasson's user avatar
0 votes
1 answer
44 views

Test class for batch with another class called in it: Batch has 100%, but called class only 24% coverage [duplicate]

Batch class: public class BatchClassForCustomer implements Database.Batchable<sObject>{ public Database.QueryLocator start(Database.BatchableContext bc){ string query='...
Pratik Bokade's user avatar
0 votes
1 answer
124 views

How can I query deleted contacts using a query through the REST API?

I am sending a SOQL query through the REST API @ <baseurl>/services/data/v55.0/query/?q=<query> I need to get deleted contacts. I just deleted a contact as a test and I cannot query it. ...
ThomasRones's user avatar
3 votes
1 answer
187 views

SOSL Find query not returning Standard Profiles, only Custom

Hello! I have a lookup component that uses a dynamic query based around FIND. It works great except when querying Standard Profiles. If I search for profiles, only custom profiles are returned. ...
Tom Adam's user avatar
0 votes
1 answer
74 views

How to change the filterable property in a schema

I was working on an error in one of my queries and found filterable property in schema, and determined that filterable was set to false (using workbench as the aforementioned question answers). How do ...
zoboso's user avatar
  • 15
-1 votes
1 answer
181 views

How to add query fields to Map?

I'm trying to add QueueId information from soql query and trying to put into another Map - groupDetailQueueIds. Map<Id, QueueSobject> groupDetailQueueIds = new Map<Id, QueueSobject>(); ...
Basha's user avatar
  • 5
1 vote
1 answer
1k views

I have an Accounts with multiple related Contacts. How can I retrieve only one Contact for each Account?

I have an Accounts with multiple related Contacts. My requirement is to retrieve one contact record for each account. If one Account has multiple Contact, I just want to retrieve one Contact record. I ...
newbieApexLWCDev's user avatar
3 votes
1 answer
145 views

Enforce User Mode in Dynamic SOQL - String or Parameter?

Is it equally appropriate and safe to use each of those Dynamic SOQL calls with USER MODE or should I prepare one over the other? The official documentation doesn't make that clear. User Mode as part ...
Robert Sösemann's user avatar
-2 votes
1 answer
54 views

How to filter non-related object by query

I have two non-related objects, Product and Lead and they have 3 matching fields with picklist type. I want to query product whose field 1 = field 1 of lead
Nitin Agrahari's user avatar
-1 votes
1 answer
99 views

Using text field in a LIKE function for SOQL query

I'm trying to query all email messages where the ToAddress contains the case contact email address. I want to know if it's possible to run a query using a text field rather than a string literal when ...
Tiramisu's user avatar
0 votes
1 answer
38 views

Need help for Contacts query to incoorporate to a visualforce page

I'm trying to create an apex class and visualforce page to create a query that pulls all contacts that the Picklistfield__c contains "associate". we also want to add a sub query that will ...
Adrian Reclosado's user avatar
1 vote
2 answers
568 views

Dynamic SOQL Error: Unexpected Token ':' - I have searched for two days, what could I be missing?

I have a batch class that will be performing some actions over selected Case records. The only problem with this batch class is the Start method. When the query is returned and processed, it returns ...
Emmanuel_M's user avatar
0 votes
2 answers
357 views

Nested query works in salesforce inspector but not in request with query in url

I'am trying to get(request) Accounts with some informations from child called Services__c. When im performing query in inspector it works fine SELECT Legal_Name__c, Name, BillingCountry, (SELECT ...
B.G's user avatar
  • 23
0 votes
0 answers
147 views

SOQL query error on CPU TImeout for Batch Apex

I have a Batch Apex operation that is part of a managed package that is failing in the start() method or soon after since the start() log is the last one displayed. I run a SOQL query that gets all ...
bswartz's user avatar
  • 27
0 votes
0 answers
72 views

Too many SOQL queries: 101 in a Flow

a question regarding this error. I recently encountered this issue when testing out a record triggered flow that I deployed in one of my organization's environment (SIT) however, I tried replicating ...
Jaemy Malik's user avatar
2 votes
0 answers
49 views

Cannot query 'AutomatedAction'?

According to the Object Reference, AutomatedAction is a Standard Object available in API 57.0 and later. However, I have tried querying it from Developer Console, from Apex, and via SOAP API in a ...
Jason Clark's user avatar
  • 11.9k
-3 votes
1 answer
55 views

SOQL to get 3 months no stage movement on the opptuity

I want to make a batch class to auto closed lost opportunity if 3 months no stage movement Now I made this SOQL in Database.QueryLocator start: SELECT Id, Name FROM Opportunity WHERE Id IN (SELECT ...
Mustika Farma's user avatar
-2 votes
1 answer
216 views

Finding Contacts that have, and do not have file attachments

Completely new to SOQL (but not SQL). Using Developer Console I have two aims: I want a SOQL query to list Contact records that have at least 1 file attached to them. I want a SOQL query to list ...
JayAy's user avatar
  • 3
-2 votes
1 answer
46 views

Ways to Match multiple set in a trigger to give an error when match is found

Ways to Match multiple set in a trigger to give an error when match is found my below trigger is executing when its finding match with content even its with different account please suggest a way to ...
user121960's user avatar
4 votes
2 answers
693 views

ApexSOQLInjection clarification with respect to binding of variables

I went through the trailhead module on SOQL injection, however I am not clear on below items: Scenario 1) Is escapeSingleQuotes here needed ? // Consider that userinput is coming from user userinput =...
Kiran Machhewar's user avatar
1 vote
0 answers
97 views

SOQL returns nickname instead of User.Name for partner user

I've a following SOQL query which returns name for regular users. SELECT Name,Title,Email FROM User But it returns nickname for the partner users. I've made sure to turn off the "Show nicknames&...
Jayakrishnan's user avatar
0 votes
2 answers
210 views

How to retrieve User.IsPortalEnabled info from CreatedBy field on a object like Feed Item using Apex and SOQL in Salesforce [closed]

I have used this query using TYPEOF operator in SOQL which returns me records in Workbench, but not sure how to retrieve values in actual apex code as it keeps on giving error. This is the query: ...
Sfdc's user avatar
  • 29
-1 votes
1 answer
344 views

This is one of the sample complicated query I am using to pull data from salesforce using ADF but some don't work

Examples of queries which don't work Select TYPEOF Owner WHEN User THEN FederationIdentifier, Title, Department END, VFS_External_Id__c From genesis__Applications__c SELECT TYPEOF Owner WHEN User ...
Jithu Tom's user avatar
1 vote
1 answer
289 views

Deleted CampaignMember records are still coming up in the SOQL query result

Some CampaignMember records are deleted and after that when I run a SOQL query without any filter criteria in code or query editor, it fetches all the campaign members with deleted ones, also their ...
Vishal Prajapat's user avatar
1 vote
1 answer
160 views

How Do I Break Down a JSON Array Format CSV Column Into Individual Columns Within SFMC Data Extensions?

I have an interesting use-case where I am getting a Data Extension from CDP where one of the columns is in JSON Format. Now I want to break down the last column of this DE into its individual columns....
aryashah2k's user avatar
-2 votes
1 answer
54 views

Error in SOQL Query

I am trying to form the required query as String searchValueFromUser = '\'' + String.escapeSingleQuotes(searchKey) + '%\''; String recordType = '\'Legal_Entity\''; String sQuery = 'SELECT Id, Name,...
Shekher's user avatar
  • 23
-1 votes
1 answer
176 views

Check if user have set security Question

Is there a soql that system admin can execute to list users who have set security question during their past logins? Thanks,
MBM's user avatar
  • 129
0 votes
1 answer
277 views

SOQL query to find Tasks by Subject and Count

We are trying to find tasks of the same Subject that occupy a lot of records. For example, there might be 4,000 tasks all titled "Opportunity closing in 3 days" and we want to find all ...
iamreallyunderqualified's user avatar
-2 votes
2 answers
459 views

Dynamic SOQL with bind variable when variable equal to null

I saw some strange from my point of view behavior for SOQL in apex when tried to compare with variable that is null, like: Date notInitializedBirthdate; List<Contact> cnts = [ SELECT Id, ...
Aliaksandr Luferau's user avatar
0 votes
0 answers
41 views

I want to solve the Too many SOQL queries. How can I reduce the number of queries?

Multiple queries are being executed depending on the data type as follows. I want to reduce the number of queries as much as possible. What should I do? //Get contract event for(ContractInfo__c ...
aeonyet's user avatar
  • 11
-2 votes
2 answers
100 views

Adding AND dynamic condition in SOQL

Hi I am trying to add an AND condition in the below SOQL but returning me null value. public static List<sobject> findRecords(String searchKey, String objectName) { string recordType = '...
Shekher's user avatar
  • 23
7 votes
1 answer
637 views

Possible bug in SOQL LIMIT clause

I've just encountered a weird behaviour of SOQL and I wonder if it's a bug or maybe some feature I do not understand: looks like the compiler lets you add an incorrect LIMIT clause - LIMIT1 for ...
Bartosz Śliwiński's user avatar
0 votes
1 answer
142 views

LWC component not showing desired result getting printed empty

I created a LWC component for a Donation Tracking app that should print in a list all the donors with their total Donations on the Home page and App page. But in the result an empty lwc component is ...
Shashank Singh's user avatar
-1 votes
1 answer
76 views

SOQl Injection Checkmarx issues

I am getting SOQL Injection checkmarx issue even after applying escapeSingleQuotes. Can you pls tell what should I apply to remove checkmarx issue. Here is Code public static Interaction__c ...
Shivanshu's user avatar
2 votes
2 answers
298 views

SOQL for ApexTrigger filtered on Name field returns no results

querying all my trigger name filtering by specific name. But no result found ? what is that I am missing ? Note: Same query works perfectly in production
Ragul's user avatar
  • 541