Questions tagged [soql]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
36 views

Dynamic simple_salesforce query with list of ids

This 2nd format_soql is not working. I have tried replacing the single quotes to double quotes as per the format defined here: https://github.com/simple-salesforce/simple-salesforce#queries query1 = &...
0
votes
2answers
38 views

get count of all the fields containing data in a specific object

public static Map<String, decimal> getFieldsCount(String objectName){ Map<string,Schema.SObjectField> get_F_name=Schema.getGlobalDescribe().get(objectName).getDescribe()....
0
votes
0answers
27 views

System.DmlException: Upsert failed - UNABLE_TO_LOCK_ROW [duplicate]

I am trying to do an upsert using Database.Upsert() and getting this error: "caused by: System.DmlException: Upsert failed. First exception on row 200; first error: UNABLE_TO_LOCK_ROW, unable to ...
0
votes
0answers
12 views

Why do translated Knowledge Articles do not have a related DataCategorySelection record?

Used example relationship query found here: https://developer.salesforce.com/docs/atlas.en-us.knowledge_dev.meta/knowledge_dev/sforce_api_calls_soql_relationships_query_datacat.htm Translated ...
0
votes
1answer
42 views

How to Ignore Not Existing Field in SOQL Dynamic Query

String objkey='Opportunity'; string recordID = '0061k000007Pyuf'; string soqlQueryCurrent='Id, Name, currency_Culture__c'; string queryStr ='SELECT '+soqlQueryCurrent+' FROM '+objkey+ ' WHERE id=:...
0
votes
0answers
7 views

Query on Data Categories within a Data Category Group

I am trying to retrieve Data Categories. The answer to this question answers the initial part of getting the label of the Category Group. How do I get the label of each category under the Category ...
2
votes
0answers
33 views

Lead object marked as Private org wide default but SOQL returns Public for DefaultLeadAccess

I have modified the Org wide default for Lead to Private. However, when I execute the SOQL to get org wide defaults - Select DefaultAccountAccess, DefaultLeadAccess From Organization, I am getting ...
0
votes
1answer
26 views

SOQL Lookup != null condition in where clause is Selective or Non Selective?

I have a batch class to process some records Select Field1, Field2 from Object where Lookup_Field__c != null && Date_Field__c in (Date1, Date2) Now the Object that this query is on has more ...
0
votes
1answer
29 views

How to get count of all Events associated with same Opportunity

There are six Events created for Opportunity 'ABC' with the same Subject name and I need to count all these Events based on Status field. I am using the below query for fetching the Events but it ...
0
votes
2answers
23 views

SOQL Lookup from custom object to Account

Let's say I have Lookup between custom object and standard Account object as a master. But select id, name, Account.id from MyObect__c always returns an error 'Didn't understand relationship Account ...
0
votes
2answers
35 views

Trigger with bind Variable

I created a trigger on account object, that needs to populate a number field called 'ContactPhones'. The input of ContactPhones, must be equal to the related contacts of the inserted account, with the ...
0
votes
0answers
26 views

How to write test class that retrieves the account history data? [duplicate]

I am using an apex class(HistoryManager) which has a method getHistoryRecords that takes 2 parameters namely a soql query(String) and a recordId(String) and calling it in the connectedCallBack() ...
2
votes
1answer
46 views

Master-detail relationship SOQL query works in dev console but not Apex

I have a junction object that links a meeting note to contacts who attended the meeting. It is a master-detail relationship. How do I get the name of the linked contact too in Apex? It works in ...
0
votes
0answers
17 views

Report filtered based on history

I have a task to create a bit of a complicated report, and I am wondering if and how this is possible. The background is that our Lead object's "Status" picklist field has 2 values (for the ...
1
vote
2answers
39 views

Index SOQL Query has a cost of 7.8

I've got a SOQL query that takes a very long time to run that's part of a larger Apex class. Below is a quick explanation of our org setup, the purpose of the query, and the query itself. Any help to ...
0
votes
3answers
52 views

Apex, Null Check

How to check if this query has return any record or not? Account accnt = [SELECT Id FROM account WHERE Id =: accId limit 1];
0
votes
2answers
35 views

SOQL - ignore custom field if non existent in object

String objkey='Opportunity'; string recordID = '0061k000007Pyuf'; string soqlQueryCurrent='Id, Name, currency_Culture__c'; string queryStr ='SELECT '+soqlQueryCurrent+' FROM '+objkey+ ' WHERE id=:...
0
votes
2answers
25 views

How can I call all Cases using SOQL query to mass delete all my Case's?

This is my code to mass delete my Cases: List<Case> caseList=[Select CaseNumber From Case]; for(Case cases : caseList); delete caseList;
0
votes
1answer
29 views

Trigger with count SOQL

I need to count how many fields were populated in a lead, every time a Lead is created. I'm using the count() statement, to query the fields that need to be counted. In the trigger, the following code ...
0
votes
0answers
17 views

Get ALL TopicId from TopicAssignment Apex SOQL Trigger

I'm working on an apex trigger that posts a new feed item every time someone adds a topic to a knowledge article in content management console. This feed item must be tagged with the topicid of the ...
0
votes
1answer
25 views

How to create a custom Array Object based on different recordId?

I am a bit new to salesforce, so kindly help. I have different recordsIDS like from contacts, opportunities,leads and other sections, I need to use SQL Query and return the Name and Email. My code ...
1
vote
2answers
55 views

How to remove SOQL Query from the for loop by Queueable in apex

I need to retrieve the field value given subject. But the only way I find to do it is by doing a dynamic query in a For or loop. Did anyone have a solution to avoid the query in the loop? Or any other ...
1
vote
1answer
21 views

Dynamically Finding the column names and values in AggregateResult

I am looking at the Salesforce Documentation for working with SOQL Aggregate Functions and seeing that we need to leverage .get to access the specific column value. Is there a built in method for ...
0
votes
1answer
18 views

How to query for accounts which have contacts only

being a new learner im unable to fetch accounts which have contacts only with this Query==> select name,(select lastname form contacts) from account<== with this getting all accounts
0
votes
1answer
20 views

SOQL & System.today

Could someone please tell me why TODAY is better to use than System.Today()? I read online that System.today is suboptimal but I don't understand why. Thank you!
0
votes
0answers
31 views

Narrowing a selection based on values in a Map<String,String>

Each day, I want to... Upsert new/changed time logs via Apex. Generate a Map where key = Jira_Issue_c, value = Activity__c Find previously created records matching Jira_Issue_c but not Activity__c ...
0
votes
0answers
18 views

How to get notes and attachments created OR owned by the user for accounts, opportunities and contacts using SOQL

I want to list all the documents/files from Notes and Attachment related list for Accounts, Opportunities, and Contacts for a user. Also, once I have the list of such documents/files then I also want ...
2
votes
2answers
34 views

Any way to dynamically set the Relationship on an Object?

I am writing a test class for my code and am running into an issue that is annoying me. So I was wondering if there is any way to do this. I have an Apex class with some functionality that I am Unit ...
7
votes
1answer
175 views

How do I bulkify queries for directly or indirectly related records?

This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through ...
0
votes
1answer
19 views

AccountShare delete issue

I'm trying to delete all AccountShare records, but getting the below error: SHARE_NEEDED_FOR_CHILD_OWNER, account share row needed for owner or share of at least I tried adding order by inside my ...
0
votes
0answers
21 views

Why can't we use asterik symbol in salesforce soql [duplicate]

select * from customer select * from TableName Why can't we use the '*' symbol in soql as in SQL
1
vote
0answers
33 views

Marketing cloud System date vs Day light saving (Control via SQL)

I have a landing DE which have a field SystemDate and that is default to Current date. I need to write a SQL which pick data from landing DE and push into Y DE. Our SFMC stack is in Central time zone. ...
1
vote
2answers
51 views

SOQL with GMT datetime in process-config.xml

I’m having problems with this statement IN BATCH -> process-config.xml (the SOQL runs just fine running it by hand in the Data Loader Utility) I’m thinking there’s some sort of special character ...
0
votes
1answer
29 views

I have got the Exception [DEBUG|Exception: System.QueryException: Only variable references are allowed in dynamic SOQL/SOSL. ] on SOQL Query

When i have executed my code i got the exception System.QueryException: Only variable references are allowed in dynamic SOQL/SOSL. . Kindly assist me. string query3 ='select id, accountId, ...
0
votes
1answer
38 views

Need to Remove SOQL query from the for loop in code snippet , how to proceed?

I need to remove soql query from the for loop in below code snippet , how to proceed ? private static List<IoTQuoteJSON.OtherDealerCodes> getOtherDealerCodes(Id oppId) { List<...
0
votes
1answer
29 views

SOQL Group By error: duplicate alias:name

So I have the following SOQL Query: SELECT Id, Name, Week_Name__c, Contact__c, Contact__r.Name, SUM(Hours_Worked_Rollup__c) hours, Status__c, Unique_Id__c, Week_Start_Date__c, Approver__c, Approver__r....
2
votes
1answer
55 views

Anonymous Window: complex type method does not exist in Apex class

I'm trying to debug my method in the Anonymous Windows but I keep getting the infamous Method does not exist or incorrect signature error. The actual error message is: Method does not exist or ...
0
votes
0answers
26 views

Invalid identifier ' '. error on running code in anonymous window [duplicate]

I am trying to learning JSON Serialization from developer.salesforce.com in which i came accross a code snippet which i tried to run in anonymous window. Contact con = [SELECT Id, LastName, AccountId ...
0
votes
2answers
50 views

SOQL query for Map of Lists

I'm trying to use a Map of List in a query to select some specific records like that for example: ID String 1 a 1 b 2 c 2 d 2 b my Map<id,String> contains id = 1, ...
0
votes
1answer
20 views

Use a string field of one object to query another object

I have a text field (Recruiters_working_on__c) on the object ts2__Job__c that contains the names of multiple users in String form. I want to return a list of Users if the Recruiters_working_on__c ...
2
votes
2answers
63 views

In a SOQL Query for Event, is it possible to filter by an field related through the RelatedRecord?

Some of our Events are related to Opportunities. Some of our Opportunities are related to Accounts which are PersonAccounts. Some of our Person Accounts have a value for PersonMobilePhone. Is there ...
0
votes
1answer
30 views

What is the maximum number of rows that can be counted by a SOQL count query?

I recollect that: select count() from Contact will now work for more than 50,000 rows (but can't find documentation on that improvement). My question is whether or not there is a new (much higher) ...
0
votes
1answer
16 views

ContentDocumentId or LinkedEntityId using the equals operator or multiple Id's using the IN operator

I am trying to get list of all the ContentDocumentLink which are not available in a set. But when I try to get NOT IN its giving error Implementation restriction: ContentDocumentLink requires a filter ...
0
votes
1answer
14 views

Apex:inputField values not inserting

I have an <apex:form> that gathers user input for various fields on the recipient__c object and a custom controller that inserts the new record. Further in the controller I have another object ...
0
votes
0answers
42 views

SOQL query to get duplicate records

In my org there are 2 objects Proposal object (parent object) Visit object (child object) I am trying to write a SOQL query to get the duplicate visits as per visit name on individual proposal ...
1
vote
1answer
16 views

Dynamic query using In with a List with multiple fields

I have an array of this class global with sharing class JiraTimeLog { public Long worklogId; public String jiraIssue; public String milestone; public String resource; public Date ...
0
votes
1answer
13 views

NPSP Campaign/Volunteer Jobs parent query

We are using NPSP Volunteers for Salesforce package. I am trying to query camapainsg and all associated volunteer jobs. The name of the child relationship, according to the UI, is 'Volunteer_Jobs'. ...
2
votes
0answers
52 views

SOQL Query Returning Zero Rows on ContentDocumentLink (filtering on LinkedEntityId)

For my specific use case, I need to find all Content Documents on specific object records that meet a business requirement. However, when I filter by linkedEntityId on the contentDocument my soql ...
1
vote
0answers
36 views

The best way to pull an Id from a SOQL collection by using the name of the record in Apex

I am looking to set a lookup field of a new object record created in Apex by referencing a collection from a SOQL query. An example would be: List<SObject> soqlQuery = [SELECT Id, Name FROM ...
1
vote
1answer
42 views

I want to get number of user logged in to salesforce with specific profile

I want to get number of users logged into salesforce in every 30 minutes for specific profile. LoginHistory doesn't provide profilename/Id ,how can I achieve this

1
2 3 4 5
98