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 votes
0 answers
18 views

Trying to create conga solution for a LOA document

The button for this will be on the Service order line object I want it to pull fields from the related object service detail and keep getting Cant get object metadata error. SOQL Select Statement ...
0 votes
0 answers
33 views

SOQL on lookup field on standard object

I am trying to get the related Case.Origin from MessagingSession, whenever I do the query on dev console or salesforce inspector, I can get the Case.Origin. However on my actual code it doesn't return ...
0 votes
0 answers
20 views

How to modify and run SOQL query dynamically in swift/Objective-C SalesforceSDK 10.2.0?

How Update with dynamic value in the Where clause from Swift/Objective-c coding in the below 'usersyncs.json' configuration. ''' { "syncName": "syncDownUser", "syncType": ...
  • 101
0 votes
1 answer
47 views

Dynamic SOQL query giving error

I am trying to execute below query and getting error which says Unexpected token IN Can someone please help to understand what is wrong here. String str = 'SELECT Name FROM Account'; String str1='...
0 votes
1 answer
28 views

Relationship query filtering

In the example below, is it possible to filter only the Accounts that have a Contact that meets the Contact filter? As it is below it will only return Accounts where the Industry is 'media', but it ...
  • 1
0 votes
0 answers
41 views

Every SOQL query I run through sfdx is getting an error, including 'field doesn't exist' on fields that clearly exist

I'm just getting setup on my Mac, to work with my organization. I wanted to be able to open the Terminal and use sfdx to run SOQL queries but I think perhaps I missed some crucial step? I was ...
0 votes
2 answers
41 views

SOQL "no-op" WHERE clause

Is there anything I can do in SOQL to achieve the same as WHERE 1=1 in regular SQL engines? I've tried that, and WHERE TRUE=TRUE, but it's rejected. Thanks!
5 votes
3 answers
289 views

Are custom SOQL- and DML-libs superfluous with USER MODE?

As the Security model of Apex was leaky in the past, everybody who took - or as AppExchange Partners had to take - Security seriously was building or using libraries to enforce CRUD/FLS rules. The ...
1 vote
0 answers
47 views

Query plan shows very high cost for a standard indexed field

I am very confused by the plans available for this simple query which uses a foreign key as a filter. My understanding is accountid on Contact is indexed since it is a primary key and I have given a ...
-2 votes
0 answers
31 views

Retrieve ID of Lookup Field from Current Page

I am wanting to get the Opportunity ID from an Order object record to display the Opportunity Products on a VF page. I am using orderID= ApexPages.currentPage().getParameters().get('ID'); to get the ...
0 votes
0 answers
21 views

Building cross object where clause using queryBuilder

I was trying to run a test using the QueryBuilder code examples with cross object fields in the where clause. I was trying a simple query on pricebookentry: select Id, UnitPrice, Pricebook2.Id, ...
-2 votes
1 answer
45 views

Aggregate Queries: Can I return values where GROUP BY size is greater than 1?

If I say SELECT count(id), field_one__c, field_two__c WHERE field_once__c > 1 AND field_two__c < 6 GROUP BY field_one__c, field_two__c could I have it only return groups where the size ...
  • 1
0 votes
1 answer
43 views

How can I show Vacancy records that are within a certain radius of my Account records?

a Salesforce newbie here. I have a geocoded Account object, and a Vacancy object. When I click on any account record, I need to see all the vacancies that are within a 30mile radius of that particular ...
0 votes
1 answer
51 views

How to Query ContentNote in Apex and show it in LWC Component

I am running the below SOQL to query to show 5 to 10 Notes records on in a LWC component based on certain conditions SELECT Id, Title, LatestPublishedVersion.VersionNumber, LatestPublishedVersion....
  • 7,705
-2 votes
0 answers
20 views

Want to show output in datatable as shown in Image from one object [duplicate]

How to write soql nested query( Quantity(LastYear), Quantity(LasttoLastYear ) for same object( Invoice line), I want to display Product, Quantity(CurrentYear), Quantity(LastYear), Quantity(...
0 votes
1 answer
35 views

Parentheses on Dynamic SOQL Unexpected Token '('

I still dont get to know why this dynamic query executed through Database.query() is throwing Unexpected Token Error on the parenthesis char. My code so far is this: @AuraEnabled public static ...
0 votes
1 answer
47 views

SOQL : Parent to Child Syntax

This query retrieves all the account and the associated contacts for that account SELECT Id, Name, ( SELECT Id, FirstName, LastName FROM Contacts ) FROM Account WHERE Name like 'Acme%' ...
  • 77
-1 votes
1 answer
32 views

Manually delete GroupMember Record

Would I be shooting myself in the foot if I manually deleted a single record from the GroupMember object that links an inactive user to a queue? Is there something that happens when you do it via the ...
  • 97
0 votes
1 answer
33 views

Account Documents

I am using the following SOQL query to get the documents attached to an account: select LinkedEntityId , ContentDocument.Title , ContentDocument.ContentSize ,ContentDocument.Description , ...
-2 votes
0 answers
51 views

Is there a way to apply filters on a List of Objects like SOQL Where Clause

I have an object where I am allowing user to add Filter Clause in a text field and In my code I use that clause to query the records which match the filter criteria. Now my problem is that my logic ...
-1 votes
0 answers
48 views

I am getting TOO MANY SOQL QUERIES for the below code .How can i rewrite the code without having soql query inside the for loop?

public static string saveoppoty(string parentOpId,string js){ map<string,object> result = new map<string,object>(); try{ map<string,Object> ...
0 votes
0 answers
36 views

Talend Select Query doesn't work properly

I'm trying to select the last created closed won opportunity for an account, this is my query used in talend: SELECT Id, Name, CreatedDate, AccountId, StageName FROM Opportunity WHERE StageName = '...
1 vote
1 answer
46 views

Do indexed fields guarantee sort optimisation?

I have an Apex Action that queries records of a custom object called Payable__c. This object has a look-up field called InvoiceId__c. The Apex Action needs to sort Payable__c records according to the ...
  • 115
0 votes
2 answers
54 views

List of group members and their `IsActive` status

Is it possible to retrieve all users that belong to a certain group, along with the value of each user's IsActive field? Required output: GroupId Id IsActive A001 001 true A001 002 false A001 003 ...
1 vote
0 answers
44 views

Get list of all users of a public group that match criteria A or criteria B or both

I have a public group comprising six users: UserOrGroupId IsActive 001 true 002 false 003 true 004 false 005 false 006 true I would like to retrieve a list containing all active group members ...
-2 votes
1 answer
45 views

How to write soql nested query( Quantity(LastYear), Quantity(LasttoLastYear ) for same object( Invoice line),

How to write soql nested query( Quantity(LastYear), Quantity(LasttoLastYear ) for same object( Invoice line), I want to display Product, Quantity(CurrentYear), Quantity(LastYear), Quantity(...
2 votes
1 answer
72 views

How does SOQL work when mentioning something like "URL" instead of the object's API name?

I found this query in Apex class. It works and returns a list of Case records along with the related Case comments. The comments come from the query in round brackets. Can someone explain how SOQL ...
0 votes
0 answers
22 views

Internal Server Error Using SOQL DISTANCE

I'm attempting to use a Distance filter in my query to find accounts within a certain area. I've enabled the geocoding on the BillingAddress field on the account, but even the simplest query fails. ...
  • 507
1 vote
1 answer
80 views

Can you conditionally build-up a static SOQL query in Apex?

Within Apex, is there a way to build up a static SOQL query using query "parts" or "fragments"? Consider the following silly example: public with sharing class MyController { @...
  • 201
0 votes
0 answers
24 views

Does SOQL.FORMAT() always return the same formatted string as getFieldDisplayValue()?

Does SOQL.FORMAT() always return the same locally formatted string that getFieldDisplayValue() would? In lightning/uiRecordApi, there are two methods for getting the value of a field from a record: ...
  • 201
-2 votes
1 answer
59 views

Attempt to dereference null object

I'm checking the incoming value whether exist in custom metadata or not . If the incoming value exist in custom metadata record returns TRUE otherwise returns FALSE. kindly please here how to avoid ...
  • 1
0 votes
1 answer
40 views

How to Access a Value from a complex multi-relationship SOQL query?

I have this monster of a query: List<Case> updatedCases = [SELECT Id,ProductId, Vehicle__c, (SELECT Equipment__r.Maintenance_Cycle__c FROM ...
0 votes
1 answer
31 views

Query a Min Value of a Related field to a Child Object from Parent and Assign it to a new record

I am trying to find a minimum value of the field Maintenance_Cycle__c (which is a field on the Product standard object which is looked up by the Equipment_Maintenance_Item__c custom object, which is ...
0 votes
1 answer
25 views

how to query External Managed Account Output

I'm referring to this link and i want to find the AccountId of an external Managed account. I'm not sure how to query this. Or is there any way I can implement this to find the Account Id? Please do ...
0 votes
1 answer
60 views

Dynamic SOQL gives Id in LWC datable instead of object Name even using __r.Name

I need a big help with my LWC Component, I'm using Dynamic SOQL but I need to show the Name of lookup field and even using __r it shows Id, here is my codes and the view : Apex: @AuraEnabled (...
  • 1
0 votes
0 answers
29 views

SOQL Error Trying to Update Account Team Members

I am trying to update Account Teams with the Default Teams of the Account Owners if certain conditions are met. I got this working for the most part, but am running into a SOQL limit error. Here is my ...
  • 55
-4 votes
1 answer
93 views

SOQL Find all Permission Sets with a given Custom Permission [closed]

How to get all permission set has a custom permission.
  • 371
0 votes
0 answers
22 views

SOQL: get knowledge Articles and data category name in 1 query (multiple languages)

I want to select all the published knowledges articles and the data category names in one statement. When I tried this: Select Id, Question__c, language, (Select toLabel(DataCategoryName), toLabel(...
-1 votes
1 answer
48 views

Using SOQL for a batch update?

I'm fairly new to Salesforce. I'm curious if I can use a SOQL query to do a batch update? I have experience with SQL, and I know this would be easy using SQL with something like Oracle or Postgres or ...
-1 votes
1 answer
24 views

Case-Sensitive SOQL query [closed]

I have the following query: [SELECT Id, Name FROM Program__c WHERE Name LIKE :**newSearchText** AND (NOT name like 'BR_%') AND (NOT name like 'PT_%') AND Portal_Sample_Template_Lookup__c = :...
1 vote
1 answer
58 views

How to Mass Delete All Inactive Flows in an Org

I am trying to do some org cleanup and delete all inactive flows. These flows are not being referenced by other components (layouts, other flows, etc.). Currently, I am using this query to gather all ...
0 votes
1 answer
37 views

Content Document Parent ID Salesforce

I am completely lost on how to populate a ParentID for Content Documents. I would like to find the parent record (custom object record) linked to the Content Document. I have easily sorted it in the ...
0 votes
1 answer
54 views

Combine two queries into a single query without relationship

So i have Two Queries SELECT Id, DurableId FROM FieldDefinition WHERE EntityDefinitionId ='Student__c' AND QualifiedAPIName = 'Hobby__c' What i want to do is take the DurableId from the above Query ...
1 vote
1 answer
147 views

PicklistValueInfo does not returns Custom object's picklist records but only returns standard object's picklist records

So i executed this below query and it successfully returned records, SELECT DurableId,EntityParticleId,Id,IsActive,IsDefaultValue,Label,ValidFor,Value FROM PicklistValueInfo where EntityParticleId = '...
0 votes
1 answer
26 views

SOQL LIKE statement not working

I have the following folders where we save the email templates: Tenders 2021 Tenders 2022 Tenders 2023 I want to run a soql query to fetch all the email templates that are stored in the folders above. ...
  • 15
1 vote
1 answer
30 views

Query recently changed records independent of Object

All I want to do is query the last recently created/changed records in a salesforce org without specifying the object. My Usecase is simply documentation: I want to review changes made by automations ...
  • 145
1 vote
1 answer
65 views

Internal Salesforce.com Error on CUMULATIVE_LIMIT_USAGE or LIMIT_USAGE_FOR_NS

Issue: I'm experiencing a Fatal Error - Internal Salesforce.com Error while running a query that could be possibly be returning a huge number or records. Any thoughts on how to resolve this? ...
  • 11
1 vote
2 answers
73 views

How to address null-pointer exception

I Have the following apex code which is throwing a nullpointer exception on the line: points = points + value; List<JMG_ExternalSearch__c> searchList = [SELECT Id,LastModifiedDate,...
  • 2,274
0 votes
1 answer
38 views

Return the name of the account with account id

Would you help me please~ I want to return the name of the account with the string parameter (Account's ID) handed over from JS! I converted the id of the account to string in JS and handed it over to ...
3 votes
1 answer
57 views

Query Plan Optimizer Questions

I have used 2 filters where both are inclusive. However one was indexed and the other was not. Because of the non indexed field, I assumed a full table scan would be used. However, the screenshot ...
  • 121

1
2 3 4 5
116