Questions tagged [soql]
Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.
5,803
questions
0
votes
0
answers
35
views
How to perform a SOQL in clause using Apex Enterprise Patterns Selector?
I'm setting an an AEP Selector which needs to implement the following:
[select ParentId from SetupEntityAccess where SetupEntityId in (select Id from CustomPermission where DeveloperName = :name)]
...
-1
votes
0
answers
22
views
I am trying to write a query to show entitlements__c that have the same email
It tells me it's malformed.
SELECT Id, Name, Contact__r.Name, Contact__r.Email
FROM Entitlement__c
WHERE Contact__r.Email IN (
SELECT Contact__r.Email
FROM Entitlement__c
GROUP BY ...
1
vote
1
answer
20
views
Getting the top level parent account of an account in hierarchy
I have written a class that gets the id of the top level account in the hierarchy of the given account id.
public class AccountUtils {
// Create a Map to hold Account Ids and their parent Ids
...
0
votes
1
answer
25
views
SOQL query not working with GROUP BY in semi-join
Why is this SOQL query not working?
I'm trying to retrieve duplicate accounts, by I need the Id for each specific account that's why I didn't just use the subselect query which would give me a grouped ...
0
votes
1
answer
28
views
how to query the fields of a managed package object
I am trying to query list of fields for certain objects, have the following query which works fine for standard and custom objects but now for managed package objects.
SELECT QualifiedApiName, ...
0
votes
0
answers
41
views
How to Delete record from the AuthSession Object?
I have a requirement to test user authentication to see if a user can potentially login to an experience site with their credentials but then to not allow the actual login. To achieve this I used the ...
-2
votes
1
answer
34
views
How to get data from two different object with same field if there is no relation between objects using SOQL
How to get data from tow different object with same field if there is no relation between two objects using SOQL there is one common field between two objects.
I am trying the below query :
select Id,...
-2
votes
1
answer
41
views
The Error in this code is - validate CRUD permission before SOQL/DML operation (rule: secuirity - apexCRUDVioloation) what is the probable solution?
public with sharing class VehicleController {
@AuraEnabled(Cacheable=true)
public static List<Vehicle__c> getVehicleList() {
return [SELECT Id, Veichle_Name__c, Rental_Rate__c, ...
0
votes
1
answer
36
views
Security scan is complaining on setEndpoing
My company uses a security scan tool called Snyk to scan code for security vulnerabilities.
It is complaining about a Server-Side Request Forgery (SSRF) vulnerability.
The details says Unsanitized ...
-1
votes
0
answers
32
views
Use Tooling API to find all flows with a get account records element
How do I write a soql query to find all flows that have a "Get Records" for account?
Select *
From FlowRecordLookup
Where object = 'Account'
https://developer.salesforce.com/docs/atlas.en-...
-1
votes
1
answer
28
views
SOQL - how to pull list of all Asset records for an Account only if two specific Assets are present?
I’ve been tasked by our sales leadership to run a report that lists all Accounts that have 2 specific Assets. Easy enough right?
However, they want to display the list of all assets under those ...
0
votes
1
answer
37
views
How to use sort by in Apex code when using SOSL queries from different tables
Here is the code of the visualforce page:
public class moderatorpanelCtrl
{
Task tk;
public list< LoginHistory> Task {get;set;}
public list< TopicAssignment> TP {get;set;...
-1
votes
1
answer
30
views
How to load more than 255 chars data in Text Area as seperate line
How to load more than 255 chars data in Text Area as seperate line when pushing data from Mule soft is there any line break can we add
-1
votes
0
answers
28
views
Unexcepted token 'select' in vs code apex or Validate CRUD permission before SOQL/DML operation (rule: Security-ApexCRUDViolation) in third line
public with sharing class AppointmentHandler {
public static void appointmentHandlerList() {
/* Validate CRUD permission before SOQL/DML operation (rule: Security-ApexCRUDViolation) */
...
0
votes
1
answer
25
views
SOQL to get list of users related to a specific parent account
I'm trying to create a query that will fetch all the users that are associated to the parent account of an specific account. Both accounts are PersonAccount entities.
So, basically I only have the &...
-2
votes
0
answers
32
views
Fetch permission sets that contains access to a particular Apex class [duplicate]
Is there a way to fetch all permission sets and profiles that contains access to a particular Apex class using SOQL?
0
votes
1
answer
32
views
ObjectHistory sort is not working correctly (UI as well as in SOQL)
Hoping someone has in idea into what is going wrong with history object record entry and sorting. Here is the soql query i'm running:
SELECT Id,Field,OldValue,NewValue, CreatedDate FROM "...
-2
votes
0
answers
25
views
How to get the prices related to products by querying product2 object? [duplicate]
can any one help me how to get the price related to product by querying product object, this is my apex method:
public static Product2[] getAllProducts() {
return [
SELECT
...
1
vote
1
answer
46
views
Nested SOQL is working but nested joins are not working
With Summer '23 release we can query upto 5 levels down in Parent-Child Relationships. See this Salesforce release notes
My sandbox is on Summer '23 release and I was able to test my custom objects ...
-1
votes
1
answer
55
views
Apex Controller to get the total no of Accounts and Opportunities group by Owner Name
I have a requirement to get a table as below,
I was creating an apex controller as below, but its showing issues, May i know where i get wrong ?
public class AccountController {
public <...
-3
votes
2
answers
44
views
How Can make my query dynamic, I found error inside this query? System.QueryException: expecting a colon, found 'Regional'
String userFields = 'user.id, user.profile.name';
String profileName = 'Regional CS Team Member';
String userObject = 'user, user.profile';
String userCondition = 'user.profile....
3
votes
1
answer
79
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.
(...
-1
votes
0
answers
39
views
How to make a SOQL query in Salesforce to obtain a list of 'ListViews' and with which user groups they are shared?
"I have many ListViews created and I need to understand which groups they have been shared with. Is it possible to obtain this information from the ListViews object table through a SOQL query?&...
-1
votes
1
answer
21
views
Subquery in cross object
I've got 3 objects =>
-Object A has a lookup with Object B (Order)
-Obect C (case) has a lookup with Object B
I need to retreive a field on Object C to display with all the field from the Object A (...
0
votes
2
answers
53
views
Why do these two queries return different results?
I have a requirement to get the most recent task date on an account. When I use the following query, Salesforce does not return the correct answer. If I do the same query but on the task object, the ...
0
votes
1
answer
62
views
How to determine fields for which a given profile does not have read permission
Full disclosure, my expertise is not on the Salesforce side, but in .NET and SQL; however, I've been tasked with assisting my company with a data migration from our original org to a new one. The in-...
1
vote
3
answers
252
views
How to do this in one SOQL
I have a query where I need to retrieve a list of Accounts and their related childs "Commission Imports", but I only need the latest of these. I determine which is the latest based on two ...
0
votes
1
answer
46
views
How to use checkbox=true in DLRS relationship criteria?
I'm trying DLRS for the first time and I need help with an SOQL error.
I'm trying to count related contract records for each contact where tutor=true (in orange).
In my contract object, I have a ...
-1
votes
1
answer
53
views
How to avoid SOQL Query in the for loop in this scenario
How to avoid the SQL Query in this case
public static void sendSMS(List<Case> newList){
List<Case> selectedCases =[SELECT Id ,
...
0
votes
1
answer
35
views
Related list on visual page rendered as PDF
I'm trying to build a custom invoice in Visualforce page rendered as PDF, in which I'm using Opportunity as my standardController. However, I'd like to get the list products related to the Opportunity ...
3
votes
1
answer
40
views
I'm only allowed to use certain fields in SOQL run through sfdx
I'm working on a MacBook Pro, so I log into production via a browser, then I open a Terminal window and I authenticate:
sfdx auth:device:login -r https://blue.my.salesforce.com
I type in the code and ...
1
vote
2
answers
36
views
Query Lookup Relationship With SOQL Not Working
I have a SalesForce custom object named Loan__c which has a Lookup field called LoanLead__c and I'm trying to query that relationship with SOQL but I'm getting an error when I run the query SELECT Id, ...
1
vote
1
answer
19
views
Query knowledges and datacategory names in a multi language org
The article knowledges are written in two languages: dutch (master) and french. When I run this query:
SELECT Id, Title, language, articleNumber,
(
SELECT Id, DataCategoryName
FROM ...
-1
votes
1
answer
100
views
How to use tooling api to query data in Apex [duplicate]
I want to retrieve the test-coverage with tooling-soql query
SELECT ApexClassOrTrigger.Name, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate ORDER BY ApexClassOrTrigger.Name ASC
It ...
-3
votes
1
answer
40
views
I am new to salesforce and performing this query getting error
SELECT Name, Account.Id, Contact.Email
FROM Opportunity
WHERE Amount > 500 AND Contact.Email != ''
Please explain me where I am wrong.
0
votes
0
answers
26
views
Big Objects are not inserting properly but got successful message while inserting
I have inserted 50 records from email message (standard objects) to big objects by apex(database.insertimmediate). All 50 records are inserted successfully. But in big objects, i could see only 8 ...
0
votes
1
answer
87
views
Passing a List in SOQL Query
I'm trying to pass a list of 1000 account IDs and retrieve their corresponding count of Contacts and write the results to a CSV file. I'm using the Anonymous Execute window to run the code below as I ...
0
votes
1
answer
87
views
How to retrieve reportFolder.meta-xml files with the Access Type and ParentId attributes?
One can retrieve reports/dashboards via sfdx or via package.xml easily but when trying to deploy them to another org, errors like 'report folder doesn't exist' are hit if the report/dashboard is in a ...
1
vote
1
answer
52
views
to get id in the place of index number in for loop
I have a method on which I'm running loop for showing all records of particular user(account). I'm getting index number in result. I want to show id of user instead of index number.
public static ...
0
votes
2
answers
38
views
I am executing the below SOQL to get list of all upload documents today from Content Document object but for some reason I am not getting all the docs
Can you please guide me in this.
SELECT Id, Title, ContentSize, FileExtension, CreatedDate, CreatedById, createdby.name FROM ContentDocument where CreatedDate = TODAY
Also, this is working fine in ...
-2
votes
1
answer
103
views
Steps to query data directly from Apex, and return the values to my LWC?
My goal is to get the metadata for all my Opportunities in Salesforce (the address, city, and state). I was told to look into query data directly from Apex, then I can return those values to my LWC. I'...
0
votes
1
answer
40
views
Is it required to use the Developer Console to query data from Apex?
I want to query my object data directly from Apex. I was wondering if its required to use the 'Developer Console' in Salesforce, or if I can use VS Code? If you can do both which would you recommend?
0
votes
1
answer
44
views
Using the wire adapter to get metadata for my object?
I am trying to use the Salesforce Object Query Language (SOQL), and the Salesforce Object Describe API to import the objects and fields data into my JavaScript file.
I am a bit lost on where to start, ...
0
votes
0
answers
34
views
TASK RECORDS THAT DO NOT APPEAR IN REPORTS AND QUERRY (The requested resource does not exist)
When creating a report of opportunities with tasks, I noticed that there were some records of tasks that should be showing up and weren't.
When I went to analyze these tasks, I saw that the task ...
0
votes
1
answer
42
views
SOQL Query for a search bar, where records are returned based on multiple fields using only 1 input string
I am looking to create a search bar like function in my LWC component where users will be able to add records to a list based on criteria entered into a Search input component.
My issue is where it ...
0
votes
0
answers
58
views
Enable Batch Apex process several records for related objects
I'm trying to write a batch class that operates on 2 related objects(Course__c and CourseDetail__c in a master detail relationship) and this batch has to look for all the child records of each parent ...
0
votes
2
answers
48
views
How do I concatenate data from a field in Salesforce using a SOQL query
I am trying to get to here
From this data
My SOQL statement so far looks like this
SELECT Designated_Bank__c, Deposit_Date__c, Actual_Payment_Amount__c, Name FROM npe01__OppPayment__c WHERE ...
0
votes
1
answer
82
views
LAST_N_DAYS is not working as expected in SOQL query
I am running an SOQL query to get 10th, 30th and 60th days before created records to notify users to take action. I wrote a query using LAST_N_DAYS:10 OR LAST_N_DAYS:30 in WHERE condition, but the ...
0
votes
0
answers
66
views
Is it possible to query archived records for a batch delete?
We've recently built a full sandbox and realized that our storage is over 130% capacity. Some digging found that there were 7million tasks taking up 94% of our storage. In order to use the sandbox, ...
1
vote
1
answer
76
views
SOQL query for Files & Notes Related List
I'm a new developer who needs help with a SOQL query. As you know, the standard files and notes related lists on an Account do not include files/notes added on child objects (e.g., Opportunity, ...