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
120
views
getting attempt to de-reference a null object while assigning value to a list
List<SIM_Cam_Request__c> requestRecordList=new List<SIM_Cam_Request__c>();
requestRecordList = [SELECT id, name, SIM_Cam_System_Role__r.Name, deletedSimCamSystemRole__c, FROM xyztable ...
-1
votes
1
answer
91
views
SOQL query stopped working, why? [duplicate]
I had this query that was working fine, but then I needed to add some more fields and I get the error message:
There was an error when retrieving the Salesforce field information for the object or ...
0
votes
1
answer
35
views
How do I write a soql child query using the new partner object
I need to pull from a custom object and where account (look up field) where partner (child object) role = x
Original query:
select id, account
from customobject
My thought for the partner:
select id, ...
1
vote
2
answers
142
views
SOQL FOR LOOP with Selector Class
I am building a SOQL FOR LOOP and I am wondering whether or not I am getting the advantages by abstracting the SOQL Query to a separate Selector class. Should I instead be placing the SOQL Query ...
0
votes
0
answers
42
views
How to get user Managed Packages
My overall goal is to know for each app from the AppExchange Marketplace which users are using it (or are allowed to use it) in the organization.
At first I tried to fetch the Installed Packages with ...
0
votes
1
answer
200
views
How to update objects and fields without having information hard coded?
We are asking our accounts to fill out a survey with questions Q1, Q2, Q3, etc. The survey record is inserted into Salesforce, and we are building a trigger to update related records.
For example, ...
-2
votes
2
answers
481
views
Get last modified data older than 30 days from Specific Date in SOQL [closed]
I need to get the user data who did not logged to system for last 30 days from a specific Date.
Do you know how we can create a query for that? If you have any suggestions pls let me know.
Thanks
2
votes
1
answer
160
views
Transform a List<String> for use in Multi-Select Picklist where clause
I have a list of strings which I need to put together in every valid combination so that the result can be used in an includes WHERE clause of a multi-select picklist in a SOQL query. Basically, I ...
0
votes
2
answers
109
views
Test Class for SOQL(CollaborationGroupFeed Object)
I'm new Apex coding, Could anybody help me fill out the test class?
I guess it is a simple soql query statement, and I wrote a test class, but I keep getting errors and I don't know why.
I got two ...
-1
votes
1
answer
103
views
I need to run a range of IDs into my query to get the name, Parent, and Primary Address from Accounts
When I enter the following code, I keep getting the error message
Bind variables only allowed in Apex code
I am unsure how to make it so I can enter multiple IDs and get back the information I am ...
0
votes
0
answers
97
views
How to get the list of fields that are available to ADD into the Field set?
I have a requirement where I want to show the list of Fields that are available to be added into the Fieldset. But I am not getting on how to retrieve the Fields that can be added into fieldset.
I am ...
-1
votes
2
answers
218
views
return count of record collection
I am fairly new to apex and SOQL. I am trying to get a record count of a new collection list to display in VF. any hints?
Public with sharing class TestDisplayQueryList2 {
public List<...
2
votes
3
answers
939
views
Get Endpoint/URL of new named credentials
We have developed an app and we are using named credentials (now legacy) to access an external API. Based on the those we also get the URL and build slightly changed iframe srces within the APP.
At ...
0
votes
1
answer
240
views
How to query GroupMember as a subquery of User in soql?
I want to fetch GroupMember associate with each user and try the below SOQL query which doesn't work
SELECT Id, (Select Id from Groups) FROM User
But when I try the same thing with ...
0
votes
2
answers
56
views
Query for Related Attachments works in query editor but not Apex
I am trying to make a simple APEX Class that returns a records related attachments.
When I do the following SOQL query in the Query Editor I get the 3 expected results:
SELECT Id
FROM ...
0
votes
0
answers
36
views
Unrecognised USER_ID value in response body when querying Event Log Files
As per the steps outlined here, I have been querying the EventLogFiles and I can see that the response body has an attribute called USER_ID as per the docs. However, the user Id (it starts with 005) ...
2
votes
1
answer
212
views
Cannot understand how the DML works in this code
I'm very new to apex and have just started learning. I was going through soql and came across this code that I'm not able to understand.
Opportunity opp = [SELECT Id, Name FROM Opportunity WHERE Id = '...
0
votes
1
answer
64
views
In the final method of batch class sending callout fails with SOQL Limit
I have a schedulable batch class which is stateful. In execute am inserting upto 1000 records.
In final method i have a list of ids of inserted record
global void finish(Database.BatchableContext BC)
...
-1
votes
1
answer
46
views
I have account and pen object where pen is child of account. I need to query the pen record with latest created date for all account query on pen obj
I have tried the query with group by and im hitting error for malformed query
Select Count(id), name (select id,name from pens) from pen__c group by count(id) > 1
0
votes
1
answer
554
views
How can I add a "contains" criteria in a SOQL query?
I am running a simple query that takes First name, Last name, and email from a dataset. At the end of my query, I need to include to only pull the email addresses that contain ".com"
I ...
0
votes
1
answer
97
views
Where can I set in Salesforce the PlatformEventSubscriberConfig fields that are accessible (or not) to my Profiles?
It's my first time dealing with PlatformEventSubscriberConfig in our project (and I'm very new to Salesforce, still a 6-month newbie).
We have 2 orgs and I noticed that when I query in UAT (Developer ...
0
votes
2
answers
99
views
How to resolve too many SOQL after using Handler
I am using Trigger Handler for my Trigger. But still getting Too many SOQL on updateNoMaterialTool(); &
Apex Class
public class ProjectTriggerHandler {
public Map<Id, Projects__c> ...
-1
votes
1
answer
295
views
Query a Lead where MobilePhone or Phone is like
I want to query lead based on a MobilePhone or Phone key. If any of these matches, the lead should come up. But I am able to fetch the lead with every parameter e.g Id, Name, FirstName, LastName etc ...
0
votes
1
answer
420
views
SOQL accessing a custom field on another table through a join
On my Contract Object manager I have a customer field called 'Related Site'. This object is found on the Site Object. I am trying to access this by SOQL using a select on Contract. Issue is currently ...
-2
votes
1
answer
57
views
How to bulkify the code, I am facing Too many SOQL queries
The most common error any developer faces is Too Many SOQL queries while working on Trigger. In this code I am facing Too many DML on line AggregateResult.
trigger DrawingSharing on Drawing__c (after ...
1
vote
1
answer
132
views
Dynamic SOQL inside for loop
We have some legacy code in one of Salesforce orgs. While going through code, I encountered this piece of code
List<query_metadata__c> dyQueries=[select id,query__c,object__c from ...
1
vote
2
answers
818
views
Get a list of one column from a SOQL result
List<Account> accList = [SELECT Id, Name FROM Account];
List<String> names = new List<String>();
for(Account a:accList) {
names.add(a.Name);
}
Say I have 30,000 Account records ...
0
votes
2
answers
512
views
Inspector Update Data Unexpected Token
I am trying to insert the data from an excel sheet which I previously exported. I just merged two fields together. I keep getting the error message unexpected token. So I tried to not insert the whole ...
2
votes
1
answer
175
views
What are the objects/entities that are NOT allowed in an inner join SOQL query?
I've tried to do an inner join SOQL query using Events/Tasks:
SELECT Id FROM Attachment WHERE ParentId IN (SELECT Id FROM Event) LIMIT 1000
But I failed with the error:
"Entity 'Event' is not ...
0
votes
1
answer
191
views
Identifying Leads for which Accounts already exist (without a conversion relationship)
It happens that Leads are created, for which an Account already exists. How can I identify these Leads?
The combination of Name and Postalcode is sufficiently identifying a match for us.
What I tried: ...
0
votes
0
answers
123
views
Error with tag toLabel to a field of a related object
I have a simple query of a custom object with a lookup to Account object:
SELECT Id, Name, Client__r.MyPicklistField__c, tolabel(Client__r.MyPicklistField__c) MyPicklistFieldLabel
FROM ...
0
votes
1
answer
145
views
How to reduce database time used to query millions of records in a batch class?
I am running a batch class that queries Line_Item__c in our production org. The query is executed in start method of Batch class. Since we have a total of more than 12 million records in our database ...
-1
votes
1
answer
259
views
CreatedDate = LAST_N_MONTHS:3 vs CreatedDate >= LAST_N_MONTHS:3
This might be a silly question... but I'm trying to get the records created within the last 3 months. I have a custom object and I have the following two queries below. I see that the results are very ...
0
votes
0
answers
113
views
Why am I not seeing records that are ostensibly inserted?
We're creating sample data when we spin up a scratch org, and we have just added a new join table between two existing tables, but the records don't seem to be actually inserting, although the code I'...
0
votes
1
answer
97
views
Get property from object in SOQL query
I have symply query that get data from table Contact and Case ( lookup Contact).
Result squery from Case is object with field CaseNumber and Subject(Like [{"CaseNumber":"00001000",&...
1
vote
1
answer
197
views
Chunking in Apex trigger for large data sets (without hitting governor limits)
I have a after update trigger which needs 4 SOQL queries.
I also have an interface where we load 10k records for this object.
There can be a scenario where user tries to update all 10k records. The ...
0
votes
1
answer
32
views
How can I search through grandparent record to find different child records?
Income__c is a child of Borrower__c which is in turn a child of Loan__c. Scenario__c is also a child of Loan__c, all of these with Master/Detail relationships. I have a list of income records, and ...
0
votes
2
answers
70
views
Can this nested loop be done through a map?
I have the following bit of code which is a nested loop that I'd like to know if it can be replicated by using a map instead as I haven't used them before and would like to know how it would end up ...
0
votes
1
answer
87
views
How to perform the following query? [closed]
I am trying to retrieve records using ContentDocument and ContentDocumentLink but the following query isn't working as expected.
SELECT id, ContentDocumentId, ContentDocument.CreatedDate, ...
0
votes
1
answer
168
views
SOQL on OpportunityFieldHistory does not return ALL Stage changes
I have a problem with the SOQL and OpportunityFieldHistory object.
When I go to the Opportunity Stage History related list I can see 8 changes on the Opportunity Stage, but when I do the query to ...
1
vote
1
answer
231
views
Python-Salesforce edit permissions
Hello currently I am playing around python and simple salesforce library.
I succesfully connect and get data sy SOQL query, but cannot find you the way how to update records/permissions.
sf = ...
0
votes
0
answers
58
views
SOQL Query Not Finishing
I have a dynamic soql query that I'm hitting on the Contact object using database.query and it works for certain cases however there are some case where it does not end at all meaning I see in the ...
3
votes
1
answer
108
views
Why does this query exclude records if the field order is changed
I have code that works on a scratch org but isn't working in production. I've tracked it down to a query that's searching a table. The Apex code looks like this:
SELECT Id
FROM Tag__c
WHERE Name IN :...
0
votes
0
answers
96
views
Cannot query Account Number field on Order!
having an issue when querying via SOQL the AccountNumber field from the Order object despite the fact that on field level security I am able to see that it is visible to everyone. When I open the ...
0
votes
1
answer
499
views
Field is not writeable: Account_Merchant__c.Merchant_Name__c
I'm trying to chage the value of Account_Merchant__r.Merchant_Name__c, if it's blank to 'Missing name'. But i get the error Field is not writeable: Account_Merchant__c.Merchant_Name__c. What is could ...
-3
votes
1
answer
123
views
How to prevent loop in batch correct way [duplicate]
I have the following Batch which currently runs. I am still wandering if the way I set my for loops are correct. Is this solution the right way?
I have a Quote which is related by several amount ...
0
votes
1
answer
574
views
SOQL query to retrieve data WHERE field value starts with 'a' or 'A'
I'm new to SOQL and apex world and I'm writing a dynamic SOQL query where I need to retrieve all the records that's firstname starts with eighter 'a' or 'A'. Using OR operator is not working.
Example -...
1
vote
2
answers
56
views
SOQL IN operator passing dynamic List<String>
I'm not sure what I'm doing wrong but I have been trying few different way but I still able to get only on record instead of getting two records, yes I double check the data do exists.
Here is the ...
0
votes
1
answer
54
views
Nested SOQL with 4 objects
I am trying to have one SOQL query that builds a JSON for API work that I am pushing. I keep getting the error
From OpportunityLineItems) FROM Opportunity WHERE Id = :opp.Id)
...
-1
votes
1
answer
61
views
Visualforce Page: Group by Company and Consecutive Date Ranges
I have created a Visualforce Page .pdf to output Candidates and their previous Work Experiences. On the Work Experience records there is a lookup field for Company as well as fields for Title, Start ...