Questions tagged [subquery]

The tag has no usage guidance.

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

Retrieve Owner Name from the Sub Query to use in Datatable

I am trying to get the Owner Name of the Task that is associated with the contact and display it in the lightning component. The Sub Query for retrieving the Tasks associated with contact is below ...
1
vote
1answer
31 views

SOQL Sub Query to retrieve the Owner Name

I am trying to retrieve the Tasks associated with the contact by doing the Sub Query like below Select firstname,lastname,(SELECT Id,Subject,Owner.Name FROM Tasks where Status = 'Completed' ORDER BY ...
1
vote
1answer
10 views

Select foreign key for sub query when there are more than one candidates

In our Asset object, we have the standard Contact field (who, in our case, is the person who purchased the Asset). We also have a second Lookup(Contact) called Member__c who is the beneficary of the ...
0
votes
1answer
30 views

Please help with a subquery that includes Order By and a second child relationship

I've learned a lot about Salesforce querying but also have a lot to learn. I hope this question is clear. I have a lookup relationship where Restrictions__c is the parent and Actions__c is the child (...
1
vote
1answer
33 views

Are subqueries supported in SFMC SQL?

When I try the following test of a subquery in SFMC Query Studio, I get the error message "Unable to create temporary data extension: Field name cannot be blank." According to official ...
0
votes
0answers
13 views

Subquery in Apex Not Returning Anything [duplicate]

In my org, I have an Address object that relates to the Account object (the relationship name is Address_vod__r). I'm trying to get a list of related Addresses in Apex, however, my subquery appears to ...
1
vote
1answer
70 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
2answers
72 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 ...
0
votes
0answers
33 views

Query running in developer console but not through Force client in .Net

Following query runs fine in developer console and workbench but fails in .Net code which uses Force Rest client: Select Id, Name, (select contact.id, contact.firstname FROM account.contacts), (...
0
votes
2answers
438 views

Using Multiple SOQL Subqueries

I am currently in the process of bulkifying some trigger code. On a high level, I receive a list of Contact objects, then I need to find the Account associated with it, and count the number of primary ...
0
votes
1answer
126 views

Custom metadata types - subquery relationship name

Is it possible to use Custom Metadata Types in the subqueries? If yes, how? In my case, there is a custom metadata type named Custom Actions and there is a Next_Action field in it. When I query for ...
1
vote
1answer
43 views

Subquery in WHERE clause with multiple fields

I wonder if SOQL ever support multiple fields in WHERE subquery... Something like this (hope, it's self-explanatory): select whatever from Table1 where (Field1, Field2) in (select Field3, Field4 from ...
0
votes
0answers
86 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. ...
1
vote
1answer
48 views

Sub query result is 0

I want to get the Opportunity Ids of the Opportunity records that have associated OpportunityLineItems but no Revenue_Pipeline__c custom object records for a batch class. I have my sub-query which ...
0
votes
1answer
342 views

Extending WHERE clause with condition from another query

I have two different queries which give the results, however is there a way to combine 2 queries and extend the WHERE clause as below: Query 1 SELECT Id, Name, (Select ID, Name, Object_C__r.Name ...
1
vote
2answers
54 views

Combine and Query 2 Child object to a Parent Object

I was wondering can you combine 2 child objects to a parent object. SELECT SourceIp FROM LoginHistory WHERE UserId IN (SELECT Id FROM User) SELECT City FROM LoginGeo WHERE CreatedbyId (SELECT Id ...
0
votes
2answers
79 views

Rewrite query to make it without subqueries

I have some custom objects displayed on schema. I need return vacancies which have last active interview at least week ago. I have some query: List<Vacancy__c> ids = new List<Vacancy__c>(...
-1
votes
1answer
15 views

The system saves the records that fired the before trigger after the trigger finishes execution? [closed]

trigger HelloWorldTrigger on Account (before insert) { for(Account a : Trigger.New) { a.Description = 'New description'; } } Copy
1
vote
1answer
151 views

Flatten SOQL Subquery to return 1 row per ActivityHistory

I currently have this query: SELECT (SELECT CallDurationInSeconds, CallData__c, Closed_After_DueDate__c, Reminder_Date_Time_LEX__c, PrimaryWhoId, Current_User_Assigned__c, LastModifiedById, ...
3
votes
1answer
156 views

Querying Opportunities related to a contact return only Open Opportunities

I am doing subquery Of Opportunities on Contact as follows:- Select id,(select id from Opportunities) from Contact where id in (select ContactId from OpportunityContactRole) I know this will return ...
1
vote
1answer
902 views

How to iterate sub query on lightning page

I want to display the contact names and opportunity names where AccountID is not null, I am able to display the contact names, can someone please help me to display the opportunity names too? Below ...
3
votes
2answers
575 views

Left outer join safety in SOQL

I covered this post. There I met the following query: SELECT Name, (SELECT Name FROM Job_Applications__r) FROM Position__c Here is the explanation provided in the post: Note that we have utilized ...
0
votes
1answer
123 views

parent-child relationship subqueries not contributing to governor limits

As per the article Execution Governors and Limits In a SOQL query with parent-child relationship subqueries, each parent-child relationship counts as an extra query. The row counts from these ...
0
votes
1answer
3k views

Query for parent-to-child (lookup) [duplicate]

I need to query all the related children of an object, the connection is via a lookup relationship. Query as follows to illustrate: SELECT (SELECT Id FROM Orders) FROM Invoice__c Error message: ...
0
votes
1answer
858 views

How to loop trough subquery relations [MAP] and put all in 1 [MAP] [closed]

I have a before insert trigger where Relatietype__c is a junction object on contact and account. I need to compare these with a 3rd object Huishouden__c with the Huishouden__c.name field which is a ...
3
votes
1answer
3k views

Dynamic SOQL, Access Subquery Results

I'm having trouble understanding how to access each individual result returned from a subquery. The picture shows the code which: takes fields and objects chosen by a user and assigns them to String ...
0
votes
1answer
117 views

Why my soql query is returning 'RecordTypeId' instead of the fields mentioned in the query? [duplicate]

Why my soql query is returning 'RecordTypeId' instead of the fields mentioned in the query? Here's my query: SELECT Id, Name, ABC, (SELECT Id, XYZ FROM InnerObject) FROM OuterObj Note: My query ...
0
votes
1answer
25 views

What is the Correct collection class structure to hold SOQL subquery results?

I've got a scenario where a status field on the parent object needs to be updated to reflect the status of the most recently created child object. To solve this, I've done a SOQL with a subquery :- ...
2
votes
1answer
454 views

Cannot use ALL ROWS in a SOQL subquery?

I need to query all Tasks from a Case, and some of the Tasks are over a year old, which makes them invisible to SOQL unless you use the ALL ROWS keyword. I tried to use ALL ROWS in the subquery, but ...