The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
29 views

Dynamic SOQL in Map with unknow sobject?

is it possible to do SOQL for the unknown object without for loop as below string theQuery = 'Select '+fiels+' From'+obj_frm +whr; Map <Id, object> oppMap = new Map<Id, object>((List<...
0
votes
2answers
16 views

How to query parent record,given the child record I'd in Salesforce?

I have an opportunity (child) with a lookup borrower__c to account (parent). How can I query the account record,given opportunity record I'd without using borrower__r or borrower__c ?
2
votes
1answer
25 views

SOQL query of MetadataComponentDependency: “Dependency API is not enabled”

I'm trying out the Dependency API (Winter '20 beta release) to help me draw package boundaries. I ran a test query from the Dev Console using the Tooling API but immediately hit the error [object ...
0
votes
0answers
10 views

Lightning page assignments and profile assignments for certain pages changed

Some the assignments that we made for lightning pages seem to be gone and we need to be redoing this again. We are unsure as to how this happened. Is there a way for us to do some audit on who made ...
1
vote
2answers
27 views

Get SOQL result from multiple tables and use in APEX

I have two custom objects ObjA and ObjB. ObjA.b is a LookUp field for ObjB. I have written following SOQL. SELECT Id, b.Name FROM ObjA This query gives correct results. Then I need to use these data ...
0
votes
1answer
26 views

How to use Select command in SOQL to return sysdate using a generic table or No table for from clause

For tests proposes, I need to get the current system date. On Oracle we could use: SELECT SYSDATE FROM DUAL On SQL SERVER, we can use: SELECT GETDATE() On DB2 we would use: Select current ...
0
votes
0answers
23 views

Implementation restriction: You can only perform queries of the form Id='<some_value>' in Salesforce

I am Using Salesforce SOQL query to get installed packages in an organisation. I tried the following SOQL Query https://ap15.salesforce.com/services/data/v45.0/tooling/query/?q=Select+id,...
1
vote
1answer
22 views

SOQL: Delete Opportunities before deleting Contacts

I have about 1200 orphan Contacts (not related to any Account). I want to delete these Contacts, however they have related Opportunities. So obviously, I need to first delete these opportunities. ...
0
votes
0answers
10 views

SOQL query on FieldPermissions is not returning row for all the fields of the sobject?

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit,parentid FROM FieldPermissions WHERE SObjectType = 'Account' AND parentId IN ( SELECT id FROM permissionset WHERE ...
1
vote
0answers
31 views

SOQL 101 issue, Need help in trimming Trigger code

I have the following trigger which is possibly a culprit to cause this SOQL 101 issue. I am not an expert so not see what is wrong here, so I need an expert to advise and suggestions where I have ...
0
votes
0answers
28 views

Query error but no error showing

I am attempting to use workbench to run a query: select count(id), Response_CD__c, DAY_ONLY(createddate) from outreach_phone_detail_pd__c where createddate > 2019-10-10T00:00:00Z group by ...
0
votes
0answers
34 views

How to design solution for querying 200k+ records and using that inside LWC?

I have a problem statement where I need to design an LWC component to enter policy information and check if that policy already exists in the system and print a report of those that aren't in the ...
0
votes
0answers
13 views

Querying using the Tooling API

I'm looking for a App that provides functionality similar to that of the Chrome extension - Salesforce Inspector. The key thing is that it can access the Tooling API. I could use the DevConsole... ...
0
votes
1answer
42 views

Best practices for splitting SOQL query results into 3 different lists?

I have a SOQL query which is returning a list of documents. I want to be able to separate the list of docs depending on who the author is, and display the different lists in 3 different data tables ...
0
votes
1answer
36 views

How to get ID from aggregateresult[] groupedresult

I have an aggreateresult[] soql as follows: AggregateResult[] groupedResults = [SELECT id, Account__c, Account__r.Account_ID__c, MAX(Account_c__C) FROM ...
0
votes
1answer
26 views

SOQL order by 2 fields (date + integer)

I would like to sort a list with two fields for a visual force page, so it works like this: Sorted by latest SRA_Date_Time__c(datetime) + by lowest Activity (integer) Example: one lead has ...
1
vote
2answers
33 views

Help with SOQL grouping

I have a requirement where I need to display top records from an object instead of all that meets the criteria. Below is my SOQL SELECT CustomAccount__r.Name, CustomAccount__r.Country__c, Month__c, ...
0
votes
1answer
24 views

Apex Class to get the value of a field on a custom object

Just looking for a simple example of an apex class that can get a field value of a custom object so that the value can be returned into a variable on a Lightning Component. Apex Class public ...
1
vote
1answer
39 views

Count_Distinct: System.LimitException: Too many query rows: 50001 [duplicate]

I cannot understand why I am receiving the following error: Too many query rows: 50001 The first two queries work perfectly when using COUNT( id), but the last two Contacts_Reached_TR_120_Query and ...
0
votes
1answer
23 views

How to add a filter in query to only fetch specific files

I am running a SOQL query on contentversion to fetch files that are attached to opportunity. However, I am noticing that it is even pulling the notes attached to the opportunity as well. Is there a ...
0
votes
1answer
44 views

Help with the SOQL query on multiple objects

Need SOQL or SOSL query to return the Accounts Name having at least a Partner, and/or Contact and/or an Activity attached to it. So far i am able to get the account name where owner ID is '...
0
votes
1answer
17 views

Code Coverage Failing

I have tried this multiple ways with no success. I have a controller class that I need to write a test class for. I have written the test class, and see that the test method passes. However, when I ...
0
votes
1answer
47 views

How to get related contact role in SOQL-query?

Salute. I'm trying to add to the related contact list page an indication of the role of each indirect contact. In the standard page "Related Contacts" this field is, but how make it in custom - I don'...
0
votes
1answer
27 views

How do I display Opportunity ID/LinkedEntityID in content version object

I am running a query on contentversion to fetch files related to opportunity from Salesforce. However the content version records returned from the query does not tell me what opportunity id is that ...
0
votes
1answer
21 views

SOQL Query combining field value on VisualForce page instead of displaying individual values per record

I currently have a SOQL line that queries an individual field from a custom object, the name of the field is decimal_since_creation__c, this field counts the number of minutes since the creation of ...
1
vote
2answers
55 views

SOQL with 'like' is not returning data records correctly

I've a query executed using database.query() method. The query looks like this: Select Id, Name from CustomObj__c WHERE Name like '%admin, ray%' ORDER BY Name I can execute this query directly in '...
0
votes
0answers
15 views

Filter picklist values based on other objects field values

Is it possible to filter picklist values based on the 2 other object fields relation? In that case I mean for example: I have an Order Type field which on junction object is related to Region (e.g. ...
1
vote
1answer
18 views

Error accessing field in object returned from SOQL query

I seem to be missing something obvious, but haven't been able to find anything in the Apex documentation or Trailhead modules or several web searches, including here. (The examples I've found all show ...
0
votes
1answer
26 views

Multiple Objects - Conga SOQL

So I have my Conga Invoice button on my Opportunity have a query of Select a,b,c from OpportunityLineItem where Opp.id. But I also need to get the other info from Custom Object(Property) This property ...
1
vote
0answers
28 views

SOQL Combine queries to fetch Contacts with their ContactRelationRoles

I have these two queries, to fetch Contact info: SELECT Id, FirstName, LastName, Email FROM Contact WHERE Id IN (SELECT ContactId FROM AccountContactRelation WHERE AccountId = '...
2
votes
1answer
48 views

SOQL for Winter 20 Where is this used functionality

Hi I would like to know how I can query the "Where is this used" relationship via SOQL. Generally, Metadata information on Fields can be found in FieldDefinition and Entity Particle tables, but can ...
0
votes
1answer
23 views

VisualForce Page displaying ID from Soql query instead of field value

I am running a soql query to obtain the value of a specific field from a custom object and it is returning the ID of the record on the visualforce page instead of the field value that I need it to ...
-1
votes
1answer
63 views

How to avoid duplicates in Map and make the comparison correct?

I have a code to compare then values from list and from map. But I'm getting duplicates in my map and only one map value in the loop later. How can I fix it? List<Tool__c> tools = [SELECT Id, ...
0
votes
2answers
37 views

marketing cloud soql filter by row number

I've a DE which has 2M records and would like to split it to 1.1M and 0.9M using SQL query. A query like below throws error. Any thoughts? select A, B, C, ROW_NUMBER() OVER (ORDER BY ...
0
votes
0answers
30 views

Does indexing a custom field in the below scenario will help with Non-Selective query error?

Background : I have a object(Foo__c) with two columns(Value__c, Type__c). Type__c is a picklist, with two options(A and B) and Value__c is a text field. Running into Non-Selective query error when ...
0
votes
1answer
45 views

How to create a nested query that fetches opportunities, Content Document and Content Version [duplicate]

I am trying to fetch all files that are associated with the opportunities in 'XYZ' stage. I am trying to construct one nested query that would first fetch all the opportunities in that stage, then ...
0
votes
2answers
57 views

Is it possible to query Custom Metadata type record labels?

I am looking for something like, API sObject name for the Custom metadata types, the way we have for ApexClass and ApexPage. I am trying to generate a list of Custom metadata type labels, CreatedBy, ...
-3
votes
0answers
23 views

how to query SOQL for 5 related master details object [duplicate]

Sub_System__c objss = [select id,name, PRD__r.Global_Constants_Used_On_Last_Submit__r.AccountId__c, PRD__r.Global_Constants_Used_On_Last_Submit__r.FGI__c, PRD__r....
0
votes
1answer
28 views

How to query Feature Licenses and Usage-based Entitlements from Company Information via REST API or SOQL?

I wish to query the tables that make up Company Information on a periodic basis automatically. I see UserLicense and PermissionSetLicense available as sObjects in Salesforce but I do not see how I ...
0
votes
0answers
71 views

Need SOQL help with subquery

I need a query on Accounts and it's related active Instance where an Entitlement of that Account for a specific product is active. Instances and Entitlement do not have a relationship on their own. ...
0
votes
1answer
28 views

when i am trying in developer query editor console below query i am getting these error

Please find the below query and please explain me the correct query.when i am trying it was showing unknown parsing error. SELECT Count(Id), OwnerId FROM Task WHERE CreatedDate = Today AND ...
0
votes
1answer
13 views

User and Dashboard relationship

I want to setup User and Dashboard relationship following is my query. SELECT Title, FolderName, LastViewedDate, Description, RunningUserId, DeveloperName, ...
1
vote
0answers
27 views

Using composite API is it possible to pass all Id's from a GET operation to another GET operation without knowing how many objects are being returned?

With composite we can use the results from a previous operation in the next operation by using the @{ref.records[0].} syntax as so: { "compositeRequest": [ { "method": "GET", "url": "/...
0
votes
1answer
26 views

SymbolTable not supported

I am trying to find the unused methods using the Query Editor in Developer Console. I have checked Use Tooling API. Running SOQL like below: SELECT Id FROM SymbolTable WHERE externalReferences = ...
3
votes
1answer
67 views

Dynamic SOQL and Object Permissions

I am hoping someone can shed some light on this for me. I am beyond confused. I have Lightning Component that has some strings to build out a dynamic query in SOQL. It is against a custom object ...
-2
votes
1answer
28 views

Test Class Failing-Logic to process Opportunity data

I'm having trouble getting my test class to pass tests. I am Getting: System.DmlException: Update failed. First exception on row 0 with id 00654000008inR8AAI; first error: ...
1
vote
3answers
55 views

SOQL query is not working for multiple status check in Apex

I wrote below query for single status check, it is working but not for multiple status checks, it is throwing errors. String draft = 'Draft'; String cancel = 'Cancelled'; String cmpnQuery = 'SELECT ...
2
votes
2answers
59 views

SOQL Join Opportunity, OpportunityLineItem, and Custom Object

I'm trying to join two standard objects, and a custom object. I need to join OpportunityLineItem, Opportunity, and MyObject. All tables have references to each other. MyObject has ...
0
votes
0answers
43 views

Batch Apex aggregate with Dynamic SOQL query

I have a strange problem. Let me explain the thing which I am trying to achieve. Am trying to fetch more than 50000 records and perform an aggregate query from apex controller of lightning component ...
0
votes
1answer
20 views

compositeRequest Invalid reference specified. No value

I'm trying to execute the following compositeRequest but I'm getting the error. { "allOrNone": true, "compositeRequest": [ { "method": "GET", "url": "/services/data/v46.0/query/?...