Questions tagged [master-detail]

This type of relationship closely links objects together such that the master record controls certain behaviors of the detail and subdetail record.

Filter by
Sorted by
Tagged with
16
votes
2answers
3k views

Delete triggers don't cascade master to detail, so why not hand-cascade on the master?

I understand from experience that Master-Detail deletion triggers do not cascade. For example if I delete my Account the Contact deletion triggers don't fire. Having devoured the first and second ...
13
votes
3answers
8k views

Can you convert a Master-Detail relationship to a Lookup if it's referenced in code?

I've got a Master-Detail relationship on a custom object where the parent is the Account object. There are no roll-up summary fields on the Account object, and there are no formula fields on the ...
11
votes
2answers
8k views

Cannot set sharingModel to ControlledByParent on a CustomObject without a MasterDetail relationship field

I am trying to deploy an update to a custom object. The object and classes associated with it work perfectly in my sandbox, but when I try to deploy, I get the following error: Cannot set ...
11
votes
1answer
543 views

Obtaining Single Record - SOQL vs. Instantiating New Object

Background I have a custom object which has a master/detail relationship to Opportunities. Whenever a record on this custom object is created or edited, I need to update the parent opportunity (and ...
11
votes
1answer
8k views

Why can't I create a master-detail relationship between Product and my custom object?

Trying to create a master-detail relationship between my custom object (detail) and the standard product object (master). Initially it said I couldn't create this because I needed to make sure all ...
9
votes
1answer
16k views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] on opportunity

I have created an object named as "Component" which has Master-Detail Relationship with Opportunity Object. On Opportunity we have a button says "Create Component", when user clicks on it it takes ...
8
votes
3answers
6k views

Master-Detail Relationship Limit

Salesforce says "As a best practice, don't exceed 10,000 child records for a master-detail relationship." here : http://na1.salesforce.com/help/doc/en/relationships_considerations.htm What does "for ...
8
votes
2answers
2k views

Cannot set sharingModel to ReadWrite on a CustomObject with a MasterDetail relationship field

Has anybody bumped into this error when spinning a new scratch org? Here's how this happened. I created a new scratch org and created 2 objects. One had a lookup field to the other. Then I pulled ...
7
votes
2answers
17k views

Is it possible to convert a Master-Detail relationship to a Lookup?

I'm going through the Trailhead training (here), and see the following two snippets which seem to disagree: "It’s possible to change a lookup relationship to a master-detail relationship, but not ...
7
votes
1answer
2k views

How to implement Lookups in Lightning Components?

Assume you have a Lookup or Master-Detail relationship defined in the metadata and now you need a simple UI. In Visualforce lookup-controls on the UI run out-of-the-box using <apex:inputField ... /...
7
votes
3answers
4k views

Upsert Detail object without external Id

I have two related objects (Master-Detail) A -> B (where B is child of A). In addition there is only one B for a parent A. I need to upsert the B object and I only have the A.Id and other fields of ...
6
votes
1answer
1k views

“Cannot set sharingModel to ControlledByParent on a CustomObject without a MasterDetail” on an “sfdx force:source:push”

Been getting the error: Cannot set sharingModel to ControlledByParent on a CustomObject without a MasterDetail this morning when editing/adding fields to some custom objects that are in a master-...
6
votes
2answers
1k views

Master Detail Relationship

I have master-detail relationship between A-B object. A is master and B is child . Now the requirement is , that A must be public and B must be private. what's the best way to implement this.
6
votes
2answers
2k views

SOQL Outer Join Multi Level Master Detail Relationship

I am working with a 3 Level Master Detail Object Relationship: "Level 1" has "Level 2" detail records "Level 2" has "Level 3" detail records I am trying to Query "Level 1 records" and using an ...
6
votes
2answers
4k views

Custom Related List with Custom Object

I am quite new to Salesforce and have not yet any thing like the following. We have a Paper object which is looking up for authors in Contact object. We want to create to have custom related list of ...
6
votes
2answers
2k views

profile object permissions for a detail record

When readng through trailhead salesforce I came across a line which I am unable to digest. The line says - "You can’t set profile object permissions for a detail record". What does this mean? In my ...
6
votes
1answer
1k views

Soql query on parents other child object

I want to write a soql query , My scenario is as follows. I have three objects objectA,objectB,objectC. objectA is the parent object for both objectB,objectC. objectA - objectB (Master-detail ...
6
votes
1answer
420 views

What happens to Master-Detail after deleting (Managed Package)

When I delete a Master-Detail relationship in my managed Package Will it be replaced by a Lookup, like this Knowledge arcticle says? Will there still be a Master-Detail relationship in our customers ...
5
votes
1answer
5k views

What are the implications of using a reparentable master-detail relationship instead of a lookup?

Since the Summer 12 release of salesforce it's been possible to set the "Allow reparenting" attribute on master-detail fields. This somewhat blurs the traditionally clear line of when to use a master-...
5
votes
2answers
497 views

Convert SQL query into SOQL query

I've been trying to figure out how to turn this SQL query into a SOQL query. Every time I think I am getting better with SOQL something comes along and erases that thought. Account is the parent ...
5
votes
3answers
5k views

How do you use an external ID in the import wizard to import child objects of a master/detail relationship?

OK, I need to import a few thousand records and import wizard seemed like a good choice. First I did some accounts - that went smoothly. Next I went to import some custom objects that have a master/...
5
votes
2answers
3k views

How to report on a master-detail relationship

I have a custom object named Milestones (with a field named MilestoneType) that has a Master-Detail relationship to Contact. I want to build a report where I can pull all contacts that have a ...
5
votes
1answer
342 views

When using FOR UPDATE does Salesforce also lock the child records in a master-detail relationship?

For example, say I get a List of rows to delete using FOR UPDATE. These are all parent records in a master-detail relationship. Will the children be locked?
5
votes
1answer
1k views

Update custom Lightning Component on Master when Detail “Related List” Component edited

I have a custom Lightning Component on an Opportunity Record FlexiPage, that shows a Master-Detail relationship Rollup Calculation (e.g. the count of detail records). After adding an item via the "...
5
votes
1answer
933 views

Child Record delete invoking Parent trigger

I have written a trigger on Parent__c Object (after insert,after update-This trigger creates a child__c record depending on few conditions). But when i am deleting child__c record, it invokes this ...
5
votes
1answer
463 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 +...
5
votes
2answers
164 views

How to denormalise a Master-Detail relationship

Contacts have Specialities (skills) to sell so I have a Master-Detail from Contact to Speciality. We sell Product (1/2 day, full day) for those Contacts so the Product has a lookup to the Contact. ...
4
votes
1answer
1k views

Any reason not to use Lookups instead of Master-Details for Junction object?

To build n-m relationships one needs a Linker/Junction object with two references. The Salesforce documentation recommends two Master-Detail relationships. Is there any reason why not to use two ...
4
votes
3answers
25k views

How many master-detail relationships per object?

All I see online is that each object can have 2 master-detail relationships, but on the Salesforce App Limits PDF : https://na5.salesforce.com/help/pdfs/en/salesforce_app_limits_cheatsheet.pdf It ...
4
votes
2answers
1k views

100.000 children in Master Detail relationship? What's the downside? [duplicate]

I know that Salesforce is recommending to keep the number of child records in Master-Detail relationships (MDR) below 10.000 records. In one situation I am heavily relying on Sharing being inherited ...
4
votes
1answer
229 views

Reading and writing child relationships of not-yet persisted SObjects?

I have a Parent__c and Child__c custom object connected by a lkp_Parent__c field. I now create an in-memory version (no insert) of a parent-child tree Parent__c p = new Parent__c(); Child__c c = new ...
4
votes
3answers
4k views

Look Up relation Vs Master detail relation

I have small doubt in choosing between look up field and master detail field. I have a custom object say cObj1 which should always be related to some other object say cObj2. So I can opt for ...
4
votes
2answers
6k views

Can I Update a Child Record when the Parent Changes with Workflows?

I have two objects in a parent-child relationship: job order (parent) and application (child.) I'm attempting to use workflow rules to update the status of certain applications when the job order is ...
4
votes
1answer
203 views

Does Lookup Skew affect only master-detail relationships or also lookup ones?

I've been encountering and reading a lot about data skew issues, particularly lookup skew, and I've noticed that most information I've found doesn't explicitly indicate whether this affects master-...
4
votes
1answer
2k views

Why can't Leads or Users be Masters in a Master-Detail relationship

I ask this both out of curiosity, and if I wanted to create an object that I wanted to act as a child to one of those objects I would have a better idea how I could do that. Let's say for example ...
4
votes
2answers
5k views

“maximum depth of master-detail relationship exceeded” Can't change from Look up To Master Detail

I have two Object, Current Relationship is Look Up I am trying change it to M-D. In change Field Type the field itself is "Grayed Out" with this Info. My Intial requirement was Master-Detail because ...
4
votes
1answer
956 views

Using Global Actions to Create a child record - MD relationship

Is it possible to use Global Actions in Salesforce to create a Child Record in a Master-Detail Relationship? I only see the master in the list of Target Objects.
4
votes
2answers
1k views

Is it possible to query the lookup object fields of child object?How to do it?

We have a parent object say ParentA with its associated child object as ChildA with a custom field customerName of type lookup(Account). Now I would like to retrieve AccountNumber, which is field on ...
4
votes
1answer
749 views

How do I deprecate/delete a master object part of a junction object which is part of a managed package?

Here is the scenario: As part of a managed package, we have 3 objects. Object A & Object C are Masters and Object B is the junction object between A & C. We packaged it all up and all good up ...
4
votes
1answer
7k views

Querying a Master Detail Relationship

I am currently learning Salesforce and Apex etc and I am stuck trying to write a trigger which contains a query. Here are my two custom objects: Student__c (Object) Nickname__c Email__c ...
4
votes
1answer
611 views

How to decide whether to use Text or AutoNumber for the detail object in master-detail relationship?

I am trying to decide whether to use Text or AutoNumber for the detail object in master-detail relationship. What are the considerations that may affect this decision?
4
votes
2answers
6k views

query to get child object data

I'm pretty new to SalesForce and my question should be very simple. I'm creating an extension for a standard controller of a custom object called Bill_Account_c. This object has a master detail field ...
4
votes
1answer
1k views

How to refer to an existing record in REST API composite JSON?

When using REST API composite JSON, how to refer with external id an existing record to existing Master-Detail parent from a newly created child We have the following objects: Organization__c: Has ...
4
votes
1answer
553 views

Inserting a child record using a trigger based on an external ID

I have a trigger that inserts a new child record (Training Session) below Training Module using a third object (Scheduler). Training Module contains an external ID called Training_Module_ID, but when ...
3
votes
1answer
1k views

Can Detail Objects trigger Master Object Workflows?

I want changes to detail objects to trigger a workflow on the master object. The master object has a rollup summary field which COUNTs how many detail objects have a certain field set. When I change ...
3
votes
3answers
410 views

Trigger to prevent edit on parent if there are no related child records

I've a scenario where there are 2 objects(Trail-master and Vehicles-detail) and no edits is to be allowed on parent if there are no related child records. I've tried the below code but without any ...
3
votes
1answer
203 views

Changing Master-Detail to Lookup, who becomes Owner?

When we convert a master-detail relationship to a lookup, who will be the owner of the child records?
3
votes
1answer
720 views

Do calculations on child records properties for master record

I am developing data model like master - Order, childs - Order items. There is master-detail relationship. Order items have quantity and price per each item. How do I create read-only field on master ...
3
votes
2answers
543 views

Unable to create Master Detail Relationship

I have some custom object - TestObj1, TestObj2, TestObj3.... TestObj1 - Only have 2 Master-Detail fields(With TestObj3 and TestObj4 Objects) TestObj2 - I have Master-Detail with TestObj5 now Why ...
3
votes
1answer
871 views

Unable to query child record through inner query

I have custom objects called 'Project' and 'Status Report'. Project is a parent and Status report is child in a master detail relation ship. With in trigger i wrote below query and getting the below ...

1
2 3 4 5
7