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
1
vote
1answer
13 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
10 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
41 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
33 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
39 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
0
votes
1answer
14 views

SOQL Query for Account - Junction - Account

I need to join Account (type = person account) --> Junction Object --> Account (type = business account) We have person accounts enabled on our org. I can easily write what I need in SQL, but ...
0
votes
1answer
43 views

SOQL 4 level Relationship

I am new to SOQL and working with a 4 Level parent - child Relationship: Level1 (Parent) Level2 (Child) Level3 (Grand Child) Level4 (Great Grand child) I am trying to pull records from Level1, Level2 &...
0
votes
2answers
23 views

Unable to fetch data from a custom look up field in a custom object

Here I am passing a String array of Id's to sentMail() method, trying to fetch data from a custom lookup field in a custom object Here 'Enquiry__c' is the custom look up field in the custom object '...
0
votes
1answer
19 views

Check how many records are related to an object and if one of them has a certain status

I have a request to check how many calls were made to each contact on my org until they answered the phone. Infrastructure: The Call__c object has a lookup field called ContactLookup__c that points to ...
0
votes
0answers
16 views

`ConversationDefinitionEventLog.EventLabel` cannot be grouped in SOQL or via Einstein Analytics - always returns `0`

I'm trying to do what should be a relatively simple dashboard for our Einstein Bot, we just want to figure out what the most popular dialogs are. I've found the data and it is stored in ...
0
votes
1answer
37 views

Apex retrieve timecards for sales invoice

I need to retrieve all of the timecards invoiced on a particular sales invoice. I have tied all of the objects to get the link together. Sales Invoice->Billing Event->BE Item->Timecard ...
0
votes
1answer
36 views

SOQL Help: Error when referencing a lookup. __c and __r not working

We have a custom object program__c. We have a lookup field on the Tasks object to program under 'Related To'. Below is my current query. Program__c is pulling the program code, but I want the program ...
0
votes
1answer
13 views

SOQL help: pulling field name off of a subquery [duplicate]

We have a custom object program__c. We have a lookup field on the Tasks object to program under 'Related To'. Below is my current query. Program__c is pulling the program code, but I want the program ...
0
votes
1answer
22 views

SfdcSqlException: ORA-00972: identifier is too long

I'm wokring on building custom hierarchy for accounts. I used this lib to build queries to get descendants. I have a field named AlternatParent__c (changed name, same length though). This is the field ...
4
votes
1answer
31 views

Apex AggregateResult in Managed Packages

When doing database aggregations in Apex and SOQL, we'd normally do something like this; List<AggregateResult> prodsWithPositiveQuantityRem = [ SELECT Product_Family__c, SUM(...
0
votes
1answer
20 views

WHERE condition in FeedTrackedChanges subquery

I'm trying to get information about when a specific field is changes in the Contact table using FeedTrackedChanges. I cannot use the list format that the table returns for FieldName, OldValue and ...
2
votes
2answers
95 views

ERROR: The same comparison operation (LIKE or =) must be specified for all OR conditions

I'm getting a malformed query exception: "The same comparison operation (LIKE or =) must be specified for all OR conditions". The select statement contains something like this: SELECT Id ...
0
votes
1answer
31 views

How do I query on user object to pull out records that they are involved in 5 unrelated objects?

I'm new in Apex, I'm running a schedule apex to send out email notification to Assigned_Reviewer__c on Custom object called "Patient relations Review" if the record status is "In ...
1
vote
2answers
43 views

SOQL to obtain Account Name of indirect AccountContactRelation

I'm having trouble creating a valid SOQL query. In one query I'd like to obtain fields from Contact, Account and AccountContactRelation. It is for an Apex-backed Lightning Web Component that displays ...
0
votes
1answer
57 views

How to query Email Service Address Case Owner in a SOQL query Salesforce?

I need help with the query on EmailServicesAddress object Salesforce. We have setup some Email Service Addresses for Email-To-Case and they have different queues as case owners. I need to query this ...
1
vote
1answer
37 views

Select by Folder Name for Email Template in SOQL

When I query for only a folder in Email Templates with this SOQL '''SELECT FolderName,Name FROM EmailTemplate WHERE FolderName = 'Customer Returns''' I get no data. However if I leave out the WHERE ...
0
votes
1answer
31 views

Issue accessing Custom Setting when instantiating Batch Class

I'm having issues returning values in a Custom setting (Type = List) when I'm instantiating a batch class, and I'm not sure why. I'm doing an upsert in my test class and confirming via system debug ...
2
votes
1answer
22 views

What is the best way to correctly create a string with a time queried from SOQL which needs to be displayed to Germans?

We have a custom Datetime field on a custom object, Appointment__r.Start_Date__c. At 6pm, the day before the appointment, we must send every customer with an appointment an SMS which reminds them of ...
0
votes
1answer
28 views

Reassign Cases from one queue to another queue

Could you please help me? I need to reassign Cases from one CaseOwner (Queue1) to another CaseOwner (Queue2), problem is that there are more then 40000 records. How can I do it. Thanks a lot.
0
votes
1answer
24 views

SOQL in Apex IF-Else Condition

I am trying to filter records based on the below if-else condition in apex code if (salesId != NULL) { List<Entity__c> entity = [SELECT Status__c, Item__r.Vendor_ID__c ...
1
vote
1answer
22 views

Looping through Inner Query Best Practice

Looking for some general guidance on the best way to deal with getting to and looping through inner queries of SOQL. At a high level, I have a trigger on Opportunity stage. If the opportunity stage is ...
1
vote
1answer
29 views

SOQL Query on Collaboration Group fails only in live code, not in Execute Anonymous Window or Query Tab of Developer Console

Simple SOQL Query fails to yield results in live Apex code, but succeeds in Developer Console Execute Anonymous Window and in Query Editor Tab. public void importProgramCollaborationGroupTable(){ ...
0
votes
1answer
19 views

SOQL Parent-to-child relationship query fetching Contacts and EDA child Addresses

I'm trying to retrieve a Salesforce Contact and all their EDA Address records. The Contact lookup field details in the Address object, lists the Child Relationship Name as Addresses Following ...
0
votes
1answer
32 views

Acccessing SOQL query data values in Lighting Web Component

I am trying to figure out how to display the values for a couple of fields in a Lightning Web Component that is driven by the following SOQL query: SELECT Id, ActivityDateTime, Account.Name, Who.Name, ...
3
votes
1answer
75 views

Does Database.rollback on a savepoint release Select for Update locks

I'm trying to understand Salesforce's locking mechanism. I ran a test which does the following: Calls Database.setSavepoint(). Issues a Select for Update query. Calls Database.rollback(savepoint). ...
1
vote
0answers
39 views

Can I use Apex and SOQL to import data from other objects into a new custom object?

This is my first time posting in stack exchange :) I have a Salesforce Admin Cert, but I have very little experience in the realm of writing code. So here goes. The goal of my apex code is to import ...
1
vote
1answer
28 views

Can we query State and Country/Territories Picklist via SOQL? [closed]

We need to check the validations manually in Batch Apex while creating SF Accounts? We have a scenario where we store all the data in our Custom Object (brought the data from the third party). In a ...
1
vote
2answers
52 views

Does a library exist for securely querying for arbitrary data?

I'm looking for a library we can use from Aura and Lightning Web Components in particular, to take some sort of request and return the data for it, but only if/what the user can see. Per their secure ...
0
votes
1answer
22 views

How can I make a SOQL which selects Leads filtered by a Converted Account Field not being true?

We have a requirement, after leads are converted, we are sending data to a partner about them. We have a batch process which will periodically look for newly converted leads, send the data to the ...
-2
votes
0answers
20 views

how to query specified dates from list of dates?

I have a list1 of dates and I need to query another list of dates where the condition like startdate is less than from that list1 I have used < in the above query. which is actually wrong. But I ...
0
votes
2answers
30 views

How to get related records of look up object in a single SOQL query?

I have a custom object for example, Field__c. Field Object has a look up to object called Rule__c and Rule__c has related list of Rule_Set__c Object. I have a SOQL query for fields in Field__c and ...
2
votes
1answer
39 views

DML for SOQL Result +Limits

I am trying to query list of records, make changes and update the same. I see two approaches here: Approach 1: List<Account> listOfAccToUpdate=new List<Account>(); for(Account acc: [...
0
votes
1answer
31 views

SOQL to get all Contracts for all accounts

I'm trying to get a full list of contracts for all accounts in SF. I've been using a couple of SOQLs with no luck. I'm just getting 0 results: SELECT id FROM Contract Or: SELECT id FROM Contract ...
0
votes
2answers
33 views

Trigger on account that equally divides the amount on related child contacts in such a way that the total should be equal

My question is , I need to divide the amount in such a way that the addition of all should be equal to total amount. With the below trigger my answer is coming as :- If the amount on contact is 50 &...
0
votes
1answer
30 views

Variable does not exist error - SOQL for loop

What could be the problem in below code. I am getting the error "Variable does not exist : Account" List<Opportunity> opp = [Select o.Id, o.AccountId, o.Account.Description from ...
0
votes
1answer
37 views

Working with Maps

I am passing a list of opportunities (opplist) to a method. For each opportuntiy, I have to check the description field of its related account. And based on that field, I will add the respective list ...
0
votes
0answers
18 views

Can we change format of Datetime variable in einstein chatbot Salesforce?

In Einstein Bot as I see, after client answers an question about datetime, salesforce will display our datetime with MM/DD/YYYY format. I want to change that format to DD/MM/YYYY. Can we customize ...
0
votes
1answer
28 views

SOQL Performance Impact

Does a Nested soql query has more impact on the overall performance or does it have the same performance impact as writing a normal soql(without nested query) since there is only a single server trip ...
1
vote
1answer
42 views

C# get subquery records of custom object

Let's say I have a query like this: Select Name,Color, (select Id,Amount from Custom_2__r) from Custom_1__c Where Custom_1__c.Id='111' In C# I see that 'Custom_1__c[0].Custom_2__r' is of type ...
0
votes
1answer
37 views

How to get Owner.Name?

i'm new here. I'm trying to get Owner.Name. Using SOQL in lightning APP return [Select Name, Email, Contact_level__c, Account.Name, Owner.Name, CreatedBy.Name, CreatedDate From Contact]; In ...
0
votes
2answers
34 views

Parent to Child Query on Contact and FinServ__ContactContactRelation__c object

I wanted to write parent to child query between Contact and FinServ__ContactContactRelation__c (Financial cloud standard object). In CCR object, both FinServ__Contact__c and FinServ__RelatedContact__c ...
3
votes
2answers
168 views

In a SOQL statement, what is the =: symbol?

How does = differ from =: ? My code snippet below only works when using =:, however when looking through the SOQL documentation, I mostly see examples using =. public class AccountUtils { public ...
0
votes
1answer
25 views

Unable to query fields from Related List of Custom Object - getting query exception? [duplicate]

I have a Custom Object Rule__c, And I have added another Custom object Rule_Set__c as Related list in page layout for Rule__c and when I try to query like below: @AuraEnabled(cacheable=true) ...
0
votes
1answer
29 views

Filter records by Date - SOQL

I am trying to get some duplicate records by using SOQL but i also want an analysis per day. select max(id)maxID,count(id),name, ea_System__c, ea_BusinessLine_Code__c, ea_CustomerId__c, count(Id) ...
-2
votes
1answer
31 views

Modify the SOQL

Hi i need to modify the below SOQL query by adding the one more check can someone help me out Query SELECT Id FROM Account WHERE HPR__c :number OR ADS__c = :number OR ASDR__c = :...

1
2 3 4 5
98