Questions tagged [soql]
Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.
5,989
questions
0
votes
0
answers
27
views
Can I Use the Wait/Sleep Element in a Platform Event Triggered Flow?
I have this platform event triggered flow that listens for a JSON message sent from an
external system that contains an array of objects (contacts with updated field values).
This flow:
Parses a JSON ...
0
votes
1
answer
62
views
Salesforce Flows recursion
I have a question I've been investigating but I don't seem to come to the right answer about what's the best practice.
I'm designing a record trigger flow that will run if "Checkbox A" is ...
0
votes
0
answers
39
views
For the below query I'm getting System.queryexception: only variable references are allowed in dynamic SOQL/SOSL. Please find the below code for refer
global with sharing class VIA_B2B_RecordSharing_Batch implements Database.Batchable<sObject>, Database.Stateful {
private final String query;
private final String objectName;
private final ...
0
votes
2
answers
39
views
SOQL query count of contacts with no cases
I am looking to do a SOQL query to extend this query to include the count of the number of cases related to the contact:
SELECT Id FROM Contact WHERE Id NOT IN (SELECT ContactId FROM Case)
The above ...
0
votes
1
answer
36
views
SOQL Query Error question
I am writing this post because I am having trouble creating a soql query.
I want to find the values of InspectionResult__c using the id of Stock__c.
But the query below fails. Please help. Is there ...
3
votes
1
answer
114
views
5 deep Apex soql: System.QueryException: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object
Given V61 (Summer 24), we get Apex support for 5 deep parent->child relationships. This was previously available only for REST API calls.
So, I gave it a try:
for (Account account: [SELECT Id, (...
0
votes
0
answers
29
views
Salesforce limitation for getting records using an expression
We have B2B commerce implementation. On an LWR site in an experience builder, salesforce has given an option to get cart data using an expression. What we have done is declared an api property in LWC ...
1
vote
1
answer
40
views
How to retrieve all the Public Email Templates where FolderName is 'Public Email Templates'
I have tried using the following query :
SELECT Id, Name, Subject, Folder.Name FROM EmailTemplate WHERE Folder.Name = 'Public Email Templates'
But it doesn't works.
one can query an email template ...
0
votes
0
answers
27
views
Return values from aggregate result record only
I need to have a query where I return all the values I require on the ONE record that holds the MAX date within a Group By. I know if there is just one record overall it can be done with an Order By ...
0
votes
1
answer
50
views
Handling Lookup Fields with Multiple Object Types in SOQL for a Custom LWC
I'm developing a Lightning Web Component (LWC) where users can select a root object and then choose fields they want to query. Some of these fields are lookup fields, which means they might need to ...
0
votes
0
answers
29
views
Is there a way to flip the parent/child data in an instance of SObject without a new SOQL query?
I have the following SOQL:
public List<B25__Resource__c> getByIds(Set<Id> resourceIds) {
return [
SELECT Id, B25__Parent__c,
...
0
votes
0
answers
25
views
Join User and LoginHistory results into a single table list or map
The objects User and LoginHistory have no relation although both have a property for user id. I want to join / merge the result of two queries
all active users: SharingCriteria__c, Project__c, Id, ...
0
votes
0
answers
45
views
SOQL with Field Permissions
I'm using the query in this first answer to this question and getting strange results.
The results from the FieldPermissions query is returning a name of X00e4x000... which, as I understand it, is a ...
0
votes
0
answers
44
views
Optimizing Apex Trigger Code on Opportunity [duplicate]
I've built a few custom Salesforce flows on the Opportunity object to automate processes, however I keep running into the reoccurring issue of the SOQL queries timing out and my flows failing the ...
-1
votes
2
answers
82
views
Execute a SOQL or Anonymous apex code every minute
I have a requirement where I need to execute a SOQL on Contact object every minute from 4 am to 5 am and capture the results for every execution. I don't want to create a batch apex and schedule it to ...
0
votes
0
answers
50
views
Referencing Table of a Single BU When Using a Multi-BU Marketing Cloud Instance
Summary: My reference of the child BU's synchronized table is not being recognized.
I am working in a Marketing Cloud instance that has two business units, each with their own Salesforce instances ...
-1
votes
1
answer
42
views
Retrieve the names of Accounts along with the total amount of all their associated Opportunities [closed]
I am trying below.
Retrieve the names of Accounts along with the total amount of all their associated Opportunities.
But I want the query to be on Account and not on Opportunity. Please let me know. ...
2
votes
2
answers
97
views
get Account which has highest number of opportunities
I am trying to get the account which has the highest number of opportunities.
Tried below and getting all the accountids and it's related opportunity count. But how do I only get the account record ...
0
votes
0
answers
37
views
Quote Line Group Field in Order Object always coming as null before or after insert Triggers
I want to display the values of the Subscription Vendor Name and Delivery Mode fields in the Order object.
The logic is as follows: When the order is created, it should check the Quote Line Group (...
0
votes
0
answers
25
views
Filter AppMenuItem by NamespacePrefix
I want to get a list of all apps that were created in an org. So I would filter all AppMenuItem objects by NamespacePrefix, like so:
SELECT NamespacePrefix, Name
FROM AppMenuItem
WHERE NamespacePrefix ...
-1
votes
1
answer
34
views
Why this query is failing? It looks logically correct as per the SOQL documentation
SELECT FIELDS(STANDARD) FROM Opportunity WHERE StageName = 'ClosedWon'
AND CALENDAR_MONTH(CloseDate) = CALENDAR_MONTH(TODAY) AND
CALENDAR_YEAR(CloseDate) = CALENDAR_YEAR(TODAY)
-1
votes
1
answer
42
views
Validate CRUD permission before SOQL/DML operation
I have a existing class with 2000 lines of code.
I got a requirement to "Validate CRUD permission before SOQL/DML operation".
Also, I have been given a list of Profiles and Permission sets ...
0
votes
1
answer
59
views
Get Child records to parent and Child’s to Child
I have 2 objects, Account and Connection__c. Account : Account is many:many, e.g. a Business account can be linked to multiple Individual Accounts and one Individual can be linked to multiple ...
0
votes
2
answers
36
views
Dynamically get all RelatedList from particular record
I have some problem with getting related lists from Contact.
I have in this contactRecord, few related lists.
Now by using Schema and childRelationships() i want to check if any of my related list has ...
0
votes
1
answer
28
views
How to print all the mandatory fields of a Record in an object with the help of SOQL query?
How to print all the mandatory fields of a Record in an object with the help of SOQL query.
Condition is:
I don't know how many mandatory fields are there in a record.
There could be "x" ...
0
votes
0
answers
39
views
Use Iterable<String> is not working with SOQL IN
I have a simple code with a SOQL query which uses IN method with the Iterable instance. However, Salesforce throws an error IN operator must be used with an iterable expression which is the exactly ...
-1
votes
3
answers
63
views
can we write a soql query to fetch the accounts where there should be only one or no contacts which are associated to it?
this question is asked in an interview, i tried but I was unable to create an SOQL query, is it possible to write a query like this?
0
votes
1
answer
33
views
Dynamic Soql query for a multiselect picklist
Test Data inserted:
Record1->Id = '012xxxxxxxxxxxx', Group__c = 'Assistant;Attorney;Builder Client'
Record2->Id = '012yyyyyyyyyyyy', Group__c = 'Appraiser;Builder'
String searchValue = 'Builder'...
-1
votes
1
answer
60
views
For a particular Perm Set, how to write a SOQL to query "Read Access" for all Fields (FLS) for an Object
I'm writing a Batch Job to update FLS across all objects for a particular Permission Set. I can loop the Object and Field describes. From there, it gets confusing.
To simplify, how do I use Apex to ...
0
votes
1
answer
34
views
SOQL help with ProcessInstance related objects
I'm trying to do a soql query to get me the processInstance record and the related ProcessInstanceNode, and steps. Currently i can get 2 out of the 3 connected, but i can't figure out why i cant get ...
0
votes
1
answer
41
views
Soql query: getting Folder child records when lookup field is polymorphic
I'm trying to retrieve a Folder of type ActionCadence, which contains records related to action cadence. However, I've encountered an issue with the lookup field on the ActionCadence object. The ...
0
votes
0
answers
47
views
Use multiple nested object information to generate documents using Salesforce OmniStudio
I am trying to configure Omnistudio to generate a document using fields from multiple objects listed as follows.
Account-->Order-->Order Line Item --> Invoice
Here is the SOQL query that I ...
0
votes
0
answers
41
views
How can I query ListView records based on some criteria using Force API
I have created a ListView on Accounts where Industry is 'Technology' in Salesforce.
We have a partner system which pulls Accounts from the above ListView using Force API.
In the partner system we have ...
0
votes
1
answer
36
views
Help editing formula field
I have a formula field (Price_Book_Name__c) on the Opportunity which pulls the Name from 2 lookup fields Price_Book__c (new field) and Product_Interested_In__c (old field). An opportunity may have ...
1
vote
1
answer
133
views
Apex Batch QueryLocator : SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object
I am writing a Batch Apex job that will process the Account records. In my SOQL query, I also want to query the child records of the Account SObject. The child records are for the immediate child ...
0
votes
1
answer
29
views
VisualForce page data not displaying after adding to 'Notes and Attachments'
As the below given, there is a quick action in Account page, which enters Contact details and on saving, it redirects to the Contact page where a pdf is attached in the 'Notes and Attachments' of ...
0
votes
1
answer
73
views
Querying number field not displaying correct decimal values
I have defined the field type as currency(16,2) with 2 decimal places, but when Querying in developer console or workbench getting different value like 2.0 for 2.00 or 2 or 2.0 as input value i want ...
0
votes
0
answers
30
views
ActivityHistory via Analytic cloud
Can we query all ActivityHistory not limited to account contact and other objects via Analytics cloud and get them by making an API call from a third-party system?
In Salesforce we need to use the ...
0
votes
0
answers
18
views
filterScope_values in Apex class without SOAP and REST API
I need to access filterScope_values in Apex without making SOAP or REST API callouts. While it's possible to do this with SOAP and REST API callouts, I'm unable to make these callouts from the Apex ...
1
vote
1
answer
75
views
SALESFORCE_AUTHENTICATOR Enabled for a user
How to identify if a given user is already linked with SALESFORCE_AUTHENTICATOR. I want to delink user from SALESFORCE_AUTHENTICATOR using an apex logic but before doing it I want to put a validation ...
1
vote
1
answer
161
views
How to write SOQL on custom address field?
I have created one custom object in that I have one custom address datatype field. Field name is Location__c, I'm able to build dynamic SOQL using this custom field the code is as follows:
@...
0
votes
1
answer
41
views
How to create a Map in apex to effectively bring soql outside loop for 2 objects manipulation
I have 2 objects , Account (look up to Acc landing) and Account Landing. Account landing has a field called accountid, which I need to update if the account has a acc landing associated to it.
My ...
0
votes
0
answers
117
views
SOQL query returns null field values for lookup fields when used by non admin users
I have a custom object with several custom lookup fields to other custom objects. I have a Apex class (not a trigger) that uses SOQL. And, when I traverse the lookup field and retrieve a field ...
3
votes
0
answers
62
views
Why doesn't ContentVersion Query doesn't respect OFFSET when you include VersionData?
I have some code where I have to be careful about how much ContentVersion data I load into memory at any particular time to avoid blowing the heap limit.
I was planning to do an initial query on ...
1
vote
1
answer
87
views
SOQL Subquery error
I have 3 objects wich relate to themselves, they are:
BRV_Carteira__c: Entity that specifies what can be sold to a client;
BRV_CarteiraItem__c: The itens of the BRV_Carteira__c(Master-Detail) such as ...
0
votes
1
answer
91
views
SOQL query to get Lead attributes from Account via converted account relation
I'm trying to get the Leads columns from the Account object.
This is the type of query I want to run, but it doesn't work:
SELECT Account.Name, (SELECT Name FROM Account.Leads) FROM Account
If I ...
0
votes
1
answer
70
views
Filter SetupAuditTrail query
The below query pulls in the records. I want to filter them to only see where an administrator logged in as another user.
List<SetupAuditTrail> auditTrailList = [SELECT Id, CreatedDate, ...
0
votes
0
answers
36
views
Can I take the Omni-Channel current Status from a User to use on Another object?
Is there a way to reach the current Omni-Channel Status from Users so I can use in another object?
Thanks in advance,
Best regards,
André Rödel.
0
votes
1
answer
127
views
Didn't understand relationship 'UserOrGroup' in field path [duplicate]
I am querying the GroupMember object and inside my query I'm trying to get the related Email field value from the UserOrGroupId relational field, here is my query:
SELECT Id, GroupId, Group.Name, ...
-1
votes
1
answer
223
views
Workbench SOQL - Aggregate Relationships not supported in Bulk Query
I am receiving error for the SOQL query I ran in Workbench for Bulk CSV:
Failed: InvalidBatch : Failed to process query: FUNCTIONALITY_NOT_ENABLED: Aggregate Relationships not supported in Bulk Query
...