Questions tagged [childrelationship]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
13 votes
1 answer
156 views

Can Cast Child Related List to Single SObject Record - Compiler error?

This situation came up in code review and I was sure the old version should have caused a compile fail: List<Child__c> children = new List<Child__c>(); for (Parent__c parent : parents) { ...
Adrian Larson's user avatar
  • 149k
8 votes
2 answers
17k views

Didn't understand relationship in FROM part of query call [duplicate]

I am trying to query the child record using the parent record id. I understand that we have to use the child relation name in the inner query to get the child records. select id, (select id from ...
SfdcBat's user avatar
  • 4,761
8 votes
1 answer
522 views

If I know the API Name, how can I get and work with the Schema.ChildRelationship?

Like many SFDC developers, we have SObjects which are related to other custom relationships. So, for example, MyCustomObject__c could have a relationship with MyCustomRelationship__c which in Apex we ...
Brian Kessler's user avatar
7 votes
1 answer
164 views

Programmatically Determine Which Objects Allow Lookup References to Them?

I'm wondering if there is a way, via apex, to retrieve all objects that would allow a lookup field on another object to reference them. For example, for a custom object obj1__c, I can create a lookup ...
Gary Hammell's user avatar
6 votes
1 answer
518 views

SOQL query with inner query doesn't recognize understand the relationship

I'm trying to write a SOQL query that will retrieve a list of Content sObjects and return it's related child Attribute sObjects. First I wrote the SOQL query to grab the parent records, and it ...
splatto's user avatar
  • 173
6 votes
0 answers
271 views

APEX Schema ChildRelationships: why have some relationships their relationshipName = null?

There is some strangeness in the some standard Childrelationships. Most Relationships are as expected, but let us take Account and Quote as an example: On Quote we have a standard lookup field Quote....
Uwe Heim's user avatar
  • 28.3k
5 votes
2 answers
16k views

SOQL to determine if parent has child records

Simple and short question, what is the cheapest way to query (plain SOQL) if an object has child records? I want to avoid running into limits even if there are parents with millions of child records.
noBillSide's user avatar
5 votes
1 answer
525 views

Prevent New Child Record without triggers

I am trying to find the best method, that will work both in classic and lightning, to prevent a user from creating a more than 1 child record from a parent object; e.g pressing 'New' on a related list....
user59760's user avatar
5 votes
1 answer
464 views

Any way to get Child Relationships without being bound by user permissions?

Question User object-level permissions limit the results of DescribeSObjectResult.getChildRelationships(). Are there any workarounds? I have submitted an Idea about this (https://success.salesforce....
Charles Koppelman's user avatar
4 votes
2 answers
5k views

How can I check that parent has more than 1 child?

Now I'm trying to use this to check it: List<Tool__c> tools = [ SELECT Id FROM Tool__c WHERE Date__c >= 2019-09-11T00:00:00.000Z ]; for (Tool__c t : tools) { //And I'll get here 101 ...
MichaelLev19's user avatar
4 votes
1 answer
1k views

Is it still not possible to get the Related List Label of Lookup fields via APEX?

We wrote a custom deduplication and merge tool allowing us to overcome the Salesforce limitation only to get the deduplication UI only for a few objects. Our tool needs to work on ANY SObject (custom +...
Uwe Heim's user avatar
  • 28.3k
4 votes
1 answer
651 views

Creating child relationship with reference fails via Composite Tree REST API

In my setup, Leads can have multiple Affiliates (custom object Affiliate__c), which is implemented through a child relationship and where each Affiliate consists of a name and the two related objects: ...
stan's user avatar
  • 71
3 votes
4 answers
2k views

Sub-Querying Objects, Plural Relationship Name?

This may be pretty basic I've come across something in SOQL I'm not sure I totally understand. List<Contact> con = [SELECT Id, (SELECT Id, Name, CreatedDate, ContentType FROM Attachments WHERE ...
Dan Jones's user avatar
  • 7,147
3 votes
2 answers
501 views

Child Relationships in SOQL Queries Aren't Working

So I have these 3 queries, and all of them throw an error about the relationship not being recognized. this.lineItems = [SELECT QuoteLineItems.Product2Id FROM Quote WHERE Id = :activeQuote.Id]; [...
Nate Briggs's user avatar
3 votes
1 answer
2k views

How to show Contacts of Account according to hierarchy on VF page?

I have a requirement where I need to show contacts based on Account hierarchy on Account layout. For example : The below is 3 level one,but we can have up to 5 levels **Grand Parent** - See All ...
Learner's user avatar
  • 169
2 votes
3 answers
5k views

Where do I find this related list API name to access in query?

I have a related list on my Contracts for Orders. I am querying for certain contracts, and I want to Select ID, startdate, and some other fields, along with its corresponding related list of orders. I'...
Natalie Spatharakis's user avatar
2 votes
1 answer
961 views

SOQL with conditions on children

I'm unable to finish an easy query, I could use some help on this. I got a junction object called Creche_Zone_de_Tarification__c that links two objects (Account and Zone_de_tarification__c and that ...
Alexis MASSON's user avatar
2 votes
1 answer
2k views

Bulk-API insert with sObject Tree

I am attempting to do an insert of thousands of record using the Bulk-API, which is in itself is not complicated. The thing that I am having trouble with is insert both Record and Child. For example, ...
Tekill's user avatar
  • 299
2 votes
1 answer
215 views

How do I get a label of Parent to Child relationship?

I am trying to get a label of Parent to Child relationship? for (ChildRelationship child: Quote.sObjectType.getDescribe().getChildRelationships()) { System.debug(child.getRelationshipName()); } ...
Patlatus's user avatar
  • 16k
2 votes
1 answer
2k views

Object that is used for Case Feed comments

I'd like to create a trigger that fires every time a user, either internal or an external community user, comments on a case. Here is my comment I do know that the CaseFeed object is used because ...
Tyler Zika's user avatar
  • 2,818
2 votes
1 answer
2k views

Didn't Understand Relationship - How To Find Child Relationship Name?

I have a many-to many relationship between three objects. LGFProducts, PartsinProducts, and Parts. PartsinProducts is the junction object. I want to be able to get data like the names of the parts ...
user1470901's user avatar
2 votes
1 answer
120 views

How to use Sfdc.ChatterNotes.createNote() in my visualforce page to add a Note to my custom object?

I'm trying to have a button in my VFP that'll add a Note (AttachedContentNote) to my custom object. I want my button to do the same as the New Note button from the Note's relatedList in my custom ...
Hugues Lavoie's user avatar
2 votes
2 answers
4k views

Getting SF report information using SOQL

I have a SF report created in the Salesforce of type 'Contacts With Opportunities'. I need to set the ETL automation for this report using python.: Please have a look at following screenshot: I have ...
Subhash Deshmukh's user avatar
1 vote
2 answers
1k views

SOQL with standard objects relationship query help

I need to combine these 2 queries so that I get the Case Members and Case details in one result. There are no custom fields/objects. Both queries run independently but when I try the subquery/...
Rhonda Gutman's user avatar
1 vote
1 answer
640 views

move all child records from one account to another efficiently

I did a bit of searching and didn't come up with anything so apologies if this is a duplicate, but - Situation: I am looking for a way to migrate all related object records from one (bad) account ...
Morgan Marchese's user avatar
1 vote
1 answer
9k views

How to query to get the Quote and QuoteLineItem from opportunity?

I queried quote from opportunity using child to parent relationship. I need to get the all QuoteLineItem records from quote using same query. Could anybody help on this. Soql Query: List<id> ...
magi 001's user avatar
1 vote
1 answer
5k views

How to get child relationship name from Parent Object in Apex

In the following piece of code, i am trying to do a dynamic parent - child query public static void fetchRelatedRecords(SObject primaryRecord){ String recordId = (String)primaryRecord.get('Id');...
Madhurima's user avatar
  • 1,265
1 vote
1 answer
2k views

fetching account lookup value on case in inner query

I am fetching account lookup value in class using inner soql query but it throwing error Compile Error: No such column 'Account' on entity 'Case'. If you are attempting to use a custom ...
cloudZigZag's user avatar
  • 1,366
1 vote
1 answer
3k views

Want to fetch the child relationship name from the Lookup field name?

I am developing a functionality where I am to check for the presence of Child records, before executing a part of code. I can't do hardcoding since my code is going to be a part of a managed package, ...
Shobhit Saxena's user avatar
1 vote
1 answer
2k views

How can I create a hierarchy (parent/child relationship) within the same object?

I have custom object Territory that can have a parent Territory and child Territory. For example, Territory "United Kingdom" with child territories "Scotland", "Wales", "North Ireland" etc. Each of ...
Alex Nekrasov's user avatar
1 vote
1 answer
91 views

confused while querying junction object

I am working on a batch and am writing a query but am getting confused because of the relationship... The batch is written on a junction object, Account_BOB__c, between 2 parents Account & ...
sfn00b's user avatar
  • 77
1 vote
1 answer
452 views

How can I translate a "child relationship" reference into an object API name (external software via API)?

I'm poking around, writing a Python script to fetch ".reportType" XML files for all ReportTypes in an org and then do various things to those files. First up is figuring out what tables they include. ...
k..'s user avatar
  • 1,187
1 vote
1 answer
3k views

Query opportunities with open activities

I would like to be able to query all opportunities that have open events. So far, I know how to do it with SOQL + Apex, but is there a way to do it just with SOQL? I'm looking for something like this ...
Javier García Manzano's user avatar
1 vote
0 answers
311 views

How to display child records in separate tables on Visualforce page for PDF

Hope we're all hanging in there. I'm relatively new to vf (please bear with me). I'm attempting to create a PDF via visualforce from a custom object (Deal_Summary__c) and its 5 related objects (4 are ...
Alexandra Mallow's user avatar
1 vote
0 answers
36 views

Lifecycle hook for child component?

I understand lifecycle hooks for a custom LWC. But how do I detect when a child LWC has loaded in the DOM? For example, let's say I have a <lightning-datatable> that is a child of a custom LWC I'...
jbyrd's user avatar
  • 621
1 vote
1 answer
513 views

Field update on parent object based on child criteria [closed]

I have a custom child object called Job on Account. They are in lookup relationship. The field on Account is HasOpenJob, I want that to automatically change to True, in case any of its Job's Stage ...
Lilla Székely's user avatar
1 vote
1 answer
140 views

Why are child records I'm inserting in my test class not appearing?

an amateur apex user here and I have a question which I've tried to distill below as much as I can. I have a class OrderTriggerHandlerV2 which fires when Order.OriginalContractedOrder__c gets filled ...
Tom G's user avatar
  • 170
1 vote
0 answers
505 views

Adding/removing records in a child relationship list

I am passing a list of SObjects with child relationships to a Lightning Web Component. If I query and pass my query results back to my LWC component directly, this works. In Apex: return [ SELECT ...
Matthew Souther's user avatar
1 vote
2 answers
160 views

How to structure objects so this subquery works

I have a custom object that looks like this MyObject__c -- Company__c (ref to Account) -- ParentCompany__c (ref to Account) -- CompanyType__c (picklist: Parent/Child) -- (a lot more data and ...
jwatts1980's user avatar
1 vote
1 answer
40 views

Fairly complex salesforce formula help

I'm trying to trigger a workflow rule over several criteria including a check against related objects (Line items) record type names. The idea is that if this all evaluates to true, it will trigger a ...
Laurence Evans's user avatar
1 vote
0 answers
245 views

Fetch records from child relationship using Apex [duplicate]

I have a remote action that need to fetch an object child relationship data, but the catch is that is has to be dynamic. For example, the remote action will get Case, CaseComments, list of fields in ...
Ron Dadon's user avatar
  • 163
1 vote
0 answers
50 views

SOQL query on multi object [closed]

I'm trying to build a query on workbench to get the Name and Stage of opportunities created this quarter when there is task created by rep A or rep B on that account or on any of the contacts ...
Priscila's user avatar
1 vote
1 answer
244 views

Child relationship expressions __r in SOSL [duplicate]

Is that possible to have a child relationship expressions __r in SOSL List<List<SObject>> searchList = [FIND :searchText+'*' IN All Fields RETURNING Account (id,name,industry), ...
Nick's user avatar
  • 6,934
0 votes
3 answers
2k views

SOQL & Custom relationships

I'm trying to understand how to query using relationships, I'm facing an issue I don't understand, Here is what I'm trying to resolve : I'm trying this, but it seems to be wrong.. Can you help me ? ...
Alexis MASSON's user avatar
0 votes
1 answer
86 views

SOQL required for a SQL

Cam someone please convert the below SQL query to SOQL? SQL: Select id, Name, product_code, (select product_code from product b where b.parent_id=a. id) as parent_code from product a How to ...
mani's user avatar
  • 187
0 votes
1 answer
2k views

How to do a batch job to update a field in a parent object from multiple child object fields?

I have the custom object Project, which has a child Payers. One project can have more than one Payer. Payer has a field called Billing Percentage. Payer is a child of Account and Project has a lookup ...
Renaud's user avatar
  • 1
0 votes
1 answer
417 views

Child relationship name missing

When I look at some of the Salesforce built-in objects, I notice some lookup field do not have a child relationship name defined - and I cannot set them myself. For example if I look at the "...
Alice Heaton's user avatar
0 votes
1 answer
1k views

SOQL relationship query returns objects. Why?

I have a custom object called 'Intake_New__c' that has a lookup field to an Account object called 'Third_party__c'. The account object 'Third_party__c' has a Hierarchy field on it called 'Parent ...
kratos's user avatar
  • 521
0 votes
1 answer
1k views

After Deleting Parent Object in Master-Detail relation, what happens to the triggers we have created in child object

In a master detail relationship in child object if we created trigger on child object after delete.when parent is deleted will the trigger execute?
mouli nandamuri's user avatar
0 votes
1 answer
412 views

SOQL to get Assets with AccountId different from Parent.AccountId [duplicate]

I need to get all Assets X with X.ParentId != NULL, and the X.Parent.AccountId != X.AccountId. SELECT AccountId,Id,ParentId,Parent.AccountId,RecordTypeId,RootAssetId FROM Asset WHERE ParentId != NULL ...
Omar Villasmil's user avatar