Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [soql]

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

0
votes
1answer
18 views

Find the center record in a list from custom object and purge in bi direction

I have list of records from a custom object which is sorted based on a custom field "Date_of_Occurrence__c" in DESC. The size of the list is 30000. Now i want to the first record and last record in ...
-2
votes
0answers
39 views

Need help on query optimization [on hold]

Can it be possible to optimise the query mainly in or condition check ,can we use something list and contains .please help List<PermissionSetAssignment> lstcurrentUserPerSet = [SELECT ...
0
votes
4answers
56 views

SOQL with Date filter in WHERE clause

@AuraEnabled public static List<StaffReport__c> getUserReports(String UserId, Date startDate, Date endDate) { return [Select Date__c from StaffReport__c where User__c =: UserId AND Date__c &...
0
votes
1answer
23 views

Need to Fetch If assigned PermissionSet to user have specific permission

Requirement-I need to sent true or false flag based on permissions assigned to user Permission sets. Suppose one user is having 5 permissions assigned to him/her ,I need to check(...
3
votes
1answer
44 views

How to test soql with For Update statement

I have a SOQL query that uses the FOR UPDATE statement. Actually, this query is in a selector class. Now I want to test my selector class, but how would I test that records returned by this query are ...
0
votes
1answer
26 views

Most efficient way to get all child records for a specific record

I have an account record that I want to get every single possible child record - ideally as a list of IDs. Currently I am doing the following: for(Opportunity opp : [SELECT ID From Opportunity ...
2
votes
0answers
19 views

Row count result from SELECT COUNT() not matching rows returned by SELECT id [duplicate]

Fairly new to SFDC and primarily using it as a source for our data warehouse. We're ingesting data using the Bulk API and are manually checking rowcounts through workbench. Running into an odd issue ...
1
vote
1answer
28 views

SOQL all files in folder

Using Files, is that possible? I've tried: SELECT Id, (SELECT Id FROM ContentVersions) FROM ContentFolder SELECT Id, (SELECT Id FROM ContentDocuments) FROM ContentFolder SELECT Id, (SELECT Id FROM ...
0
votes
1answer
16 views

Question on Negative operator SOQL Index or Table scan

I was reading SFDC documentation and they state that using != or Contains will almost run the query in table scan. With that said, we have 5 Million case records in production. When i check the ...
0
votes
0answers
10 views

Get content of Quote files [duplicate]

I'm stuck in retrieving the content of files attached to the Quote object of Opportunity Thanks in advance
0
votes
2answers
34 views

Help with SOQL for loop

Could anyone help me with the code bellow please? MasterIdSet - may contain one or more ids Master_ID__c - is an external id which value could be the same across one or more Accounts. I would expect ...
0
votes
2answers
32 views

SOQL Join Contact and User?

In my org, the User object has a lookup field to a Contact. In my Apex class, I need to return a data set that includes Contacts and the User Id associated with each Contact. The query below returns ...
1
vote
0answers
20 views

Related List SOQL query [duplicate]

I have the following code working: SELECT of_Loans__c, Id, ( SELECT id FROM Loans__r WHERE MtgPlanner_CRM_Status__c = 'Closed') FROM Contact After some time tinkering around, I was able to access ...
0
votes
1answer
39 views

SObject row was retrieved via SOQL without querying the requested field: s2cor__Sage_INV_Trade_Document_Type__c. s2cor__Use_Company_Shipping__c

I have a C# application that was meant to upload invoices to salesforce financials. All other functions of the application works fine except the uploading module. During the upload process, I have to ...
1
vote
1answer
24 views

SOQL Get child with most rows grouped by parent

Let's say i have the following structure Object Car is a parent of many (object) Incidents that are also children of an Area So the table of incidents looks like this INCIDENTS ID CAR AREA ...
4
votes
1answer
120 views

SOQL Not Recognizing Field?

I have this apex code: //testing code for above List<Contact> contacts = new List<Contact>(); for (MtgPlanner_CRM__Transaction_Property__c lo : [SELECT MtgPlanner_CRM__Borrower_Name__c, ...
0
votes
1answer
37 views

SOQL field/object security setting in all Permission Set

I have two questions: How to get all Permission Sets' Name/Label? How to know the Security setting in a name-knowed Permission Set? Scenario: For audit reason, I have to retrieve Object/Field ...
1
vote
1answer
32 views

Do really row counts from parent-child relationship sub-queries contribute to the row counts of the overall code execution?

Most of us know this is a very basic question but I little confused here again, As per the documentation here, it says that parent-child query row count is added to the overall row count in the ...
0
votes
1answer
22 views

Can you include only top 10 records in SOQL group?

I have the following Query [Select Supplier__c, Avg(Total_Sales__c) from Submittal group by Supplier__c order by Purchase_Date__c DESC] The issue is that I only want to include the latest 10 records ...
1
vote
2answers
107 views

How to retrieve the correct Account records from SOQL query?

In account record I have a custom myDate__c field of type date. I need to retrieve all Account records where myDate__c is older than 45 days. I've tried with the following query: SELECT id, name ...
0
votes
1answer
28 views

Trying to convert Cross-Filter Report to a SOQL query

I need to convert a cross-filter report of Leads and Activities to a SOQL query. Filters All Leads Created Date: All Time Cross Filters Leads without Activities Subject contains: voicemail, call,...
0
votes
1answer
19 views

Perform an inner join soql on arbitrary values

I have some custom fields on Account and a custom object with some custom fields. i want to find id from my custom object and id of accounts that have the same field value I tried something like: ...
0
votes
1answer
22 views

SOQL Request / data model

This is my data model : I would like to get list of Classes(Class) with class category (Product_Category__c.Name) ,price (PricebookEntry.UnitPrice) and some fieds of the Class. What I've done : ...
0
votes
2answers
59 views

How to fetch contentNote records as per the contact record?

I am trying to fetch the note title, note body as per the related contact ID in one SOQL query as two SOQL queries won't serve the purpose. In contentNote, We have the note title and note body but ...
0
votes
1answer
20 views

Query Data category tree structure by SOQL statement

Using SOQL statement, I want to query the Data Categories tree structure that I have created on Saleforce. How can I do this?
0
votes
0answers
31 views

Error while executing SOQL through rest api

When I am trying to execute SOQL using OAuthRestTemplate Rest API with following URL: https://na98.salesforce.com/services/data/v46.0/queryAll/?q=SELECT+Name+from+Account+where+SAP_ID_UCID__c+=+'...
4
votes
0answers
43 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 ...
1
vote
1answer
37 views

Getting the highest Parent Account in Salesforce Hierarchy via SOQL/APEX

I am trying to get the highest level of parent account in an Account Hierarchy in Salesforce via Apex and SOQL. I want to create and MAP<Id, Set<Account>> hierarchy in my Apex class to ...
1
vote
1answer
36 views

SOQL Like operator with %%% returns all records of given object

If i run below query it returns all records of that object: Select ID, name from Contact where Name like '%%%' This should return only those records which have % in the name. For example if i run ...
0
votes
1answer
30 views

query contacts agains variable on controller to update value

I am trying to put in a query for a value that is entered in a field on the visual force page. When the submit button is selected it will go through and query the contact data and match the email ...
3
votes
1answer
52 views

QueryException - query non selective

I recently deployed a trigger to production. Inside it was the following query: SELECT Id, (SELECT Business_Unit__c, Department__c, Role__c FROM Account_Roles__r WHERE Role__c IN :roles AND ...
-1
votes
0answers
26 views

Use Batch Apex for a Visual Force page

I am a newbie to Batch Apex so hope someone can help me out. My main aim is to search through all my contacts and return all those which are duplicates on a Visual Force page, and then a button will ...
0
votes
1answer
43 views

Can someone provide me the list of SOQL exceptions?

Can someone provide me the list of SOQL exceptions? a URL link which has all the exceptions and explanations. Thanks in advance
-1
votes
1answer
40 views

Error: Compile Error: Found punctuation symbol or operator '%' that isn't valid in Apex. at line 14 column 362

global class ABI_SFA_TAC_Removal_Batch implements Database.batchable<sObject> { // variable decleration. public String Query; /* Method Name: Start Description: This ...
0
votes
1answer
42 views

Export data from batch to csv file

I want to create a quick action button that call to apex class that execute a batch(I used a batch because I want to retrieve More than 50000 records and I have salesforce limitation). I want to take ...
3
votes
1answer
66 views

Why is the Developer Console Query Results Preview only showing 8 records when the Total Rows count is 258?

I wrote a query in the Developer Console, and when I ran it, at the top of the screen it shows "Query Results - Total Rows: 258". Below that, in the preview panel, it only shows 8 records. I know ...
1
vote
2answers
72 views

Salesforce - soql System.QueryException Try Catch Issues

I am building dynamic soql query from an object. I am getting the object in a Field and another field from a object in Salesforce for the Query. With that said I am trying to capture the Query ...
0
votes
2answers
40 views

Salesforce Database.query - Object and Where Clause Variable

I am having an issue with the database.Query. I keep getting a I think error on of my object variable doesn't exist or my where clause is incorrect. This is what I tried String strObjectName = ...
1
vote
4answers
156 views

Salesforce - Search by field without knowing object

Is it possible to SOQL Salesforce for a Record Name without knowing the object name? I will only know the of the record not the ID or Object unfortunately.
2
votes
1answer
51 views

SOQL TYPEOF Enabling

I getting an error from FormTitan (for creating forms with connection to salesforce). SOQL TYPEOF expressions are not supported for API versions less than 46.0 . I saw that my API version on my ...
2
votes
1answer
30 views

Is there any ways to identify which managed packages most significantly consume our limits?

Our org is having trouble with our SOQL and CPU Time Limits. While it is probably true that our own legacy code could be bulkified better, this is a non-trivial, non-short term solution. Our org has ...
0
votes
1answer
29 views

fetching latest login info of each user in List

I am trying to fetch the one latest login History of the each User using below SOQL query. loginHstryList=[SELECT Id,UserId,LoginTime, Platform,Status,Browser from LoginHistory where UserId =: ...
0
votes
1answer
65 views

Getting 'Bind variables only allowed in Apex code' when attempting this query

SELECT Id, Last_stage_changed_date__c, CreatedDate FROM Opportunity WHERE Last_stage_changed_date__c < CreatedDate Last_stage_changed_date__c is of the Date type. I feel like I'm doing something ...
0
votes
1answer
31 views

SOQL query using LIKE or Contains with IN [duplicate]

Are there any workarounds for creating a query using the LIKE operator on a set of strings? I would like to create a new object(Exclusions) which would house records that have a field for keywords ...
2
votes
1answer
66 views

How to query ContentDocument and Custom object's fields at once?

We have 3 objects. OS_Account_Document__c (Custom) ContentDocument ContentDocumentLink I need to query two custom fields (Document_Type__c and Custom_Document_Description__c) from the Custom Object ...
1
vote
1answer
102 views

Batch Apex: Too many SOQL queries: 201

I have created a batch apex and I get this error: Batch Apex: Too many SOQL queries: 201 while I don't have any SOQL query in a for loop. I suspect it is coming from the DatedConversionRate query but ...
0
votes
1answer
51 views

How to see log of a single bulk insert statement

Is there a way to find if the user insert the records is that through bulk statement or individual insert records? I have look DebugLog and ApexLog object but does not give me a lot of information ...
1
vote
0answers
48 views

how to avoid system.limitexception too many soql queries 101 in apex classes [closed]

when I am trying to deploy the component then I was getting this error like system.limitexception too many soql queries 101 how to avoid this? ====================================== /** * @...
7
votes
1answer
760 views

How to get MAX value using SOQL when there are more than 50,000 rows

I would like to run this query: SELECT MAX(Auto_Number__c) MaxNumber FROM Opportunity But I am getting this error: System.LimitException: Too many query rows: 50001 Because there are more than a ...
0
votes
1answer
19 views

How to get Activity History when SharedActivities is enabled/disabled

I execute the following query to get activity history for an account SELECT (SELECT Id, IsTask, ActivityDate, ActivitySubtype, Subject, Owner.Name,PrimaryWhoId,WhatId,PrimaryWho.Name, What.Name ...