Questions tagged [soql]
Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.
5,885
questions
0
votes
1
answer
28
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 ...
1
vote
1
answer
40
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 ...
-2
votes
1
answer
29
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 ...
5
votes
1
answer
119
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
...
0
votes
1
answer
44
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 ...
0
votes
0
answers
29
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 ...
0
votes
2
answers
47
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, ...
0
votes
1
answer
26
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 ...
0
votes
0
answers
41
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 ...
2
votes
1
answer
67
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: ...
0
votes
1
answer
32
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='...
0
votes
1
answer
34
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.
...
3
votes
1
answer
129
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.
...
0
votes
1
answer
23
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 ...
-2
votes
0
answers
49
views
How to seperate queueIds from Map? [duplicate]
Map<Id,QueueSobject> groupDetailQueueIds = new Map<Id,QueueSobject>();
Map<Id,QueueSobject> groupDetail = new Map<id,QueueSobject>([Select Id, SobjectType, QueueId, Queue.Name ...
-1
votes
1
answer
55
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>();
...
1
vote
1
answer
98
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 ...
3
votes
1
answer
87
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 ...
-2
votes
1
answer
37
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
-1
votes
1
answer
43
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 ...
0
votes
1
answer
35
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 ...
1
vote
2
answers
452
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 ...
0
votes
2
answers
71
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 ...
0
votes
0
answers
55
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 ...
0
votes
0
answers
51
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 ...
2
votes
0
answers
40
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 ...
-2
votes
1
answer
38
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 ...
-2
votes
1
answer
80
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 ...
-2
votes
1
answer
43
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 ...
2
votes
2
answers
276
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 =...
1
vote
0
answers
43
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&...
0
votes
2
answers
83
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: ...
-1
votes
1
answer
118
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 ...
1
vote
1
answer
128
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 ...
0
votes
1
answer
82
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....
-2
votes
1
answer
38
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,...
-1
votes
1
answer
54
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,
0
votes
1
answer
72
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 ...
-2
votes
2
answers
64
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, ...
0
votes
0
answers
32
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 ...
-2
votes
2
answers
47
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 = '...
7
votes
1
answer
606
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 ...
0
votes
1
answer
70
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 ...
-1
votes
1
answer
37
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 ...
2
votes
2
answers
182
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
0
votes
0
answers
18
views
How can I get the user-friendly label for the available permissions?
While I'm able to query the PermissionSet object and retrieve FIELDS(ALL), parsing the fields that start with Permissions to see which permissions are available, I'd like to get the user-friendly ...
0
votes
2
answers
40
views
Aggregated result error: Unexpected token 'createddate'
I have the following Aggregated SOQL
List<AggregateResult> groupedSpotOnEs = [SELECT my_application__r.numbers__r.Id eSId, status__r.name status, COUNT(Id) recordCount
...
0
votes
1
answer
40
views
Sorting Records in apex:repeat by Date: Is It Possible?
I am currently working on a Visualforce page that utilizes an apex:repeat to display records from a custom object. I would like to know if there's a way to arrange these records in ascending or ...
0
votes
1
answer
37
views
Return Soql result to a field [closed]
I'm need to return the result of a SOQL query to a field.
My object is called Metric. I have a field called SOQL which houses the SOQL query and I have a field called Result. My Query is below, How Do ...
-1
votes
1
answer
72
views
Apex : SOQL relationship query on master-detail and lookup objects in APEX
I am trying to create a single query on master-detail and lookup objects
Currently, I have three separate queries, which are able to run in Apex and get the expected results. But, the code approach I ...