function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prabodh SPrabodh S 

not able to identiy master-detail relationship from API

hi,

I am trying to identify the difference between look-up relationship and master-detail relationship.

When I call describe on any custom object then how can i identidy the which field is having look-up relationship a
nd which one is having master-detail relationship.

In short from API I need to identify if the field is having look-up relationship or master-detail relationship.
If there is any property field or any clue in schema, that can help to identify it.

Please help me out........

Thank you in advance.

Regards,
Prabodh
mtbclimbermtbclimber
There are currently 2 things that are distinct about Master-detail relationships today:

1) They are required
2) The exhibit cascade delete from the master

You can detect 1) by looking at the field's nillable property from describe and you can detect 2)from the Cascade Delete property on the child relationship from the describe of the related object.

You need to identify which makes more sense for your requirements as it is possible and likely that lookups will be able to be flagged as required someday (making them show up the same as M/D from a nillible property perspective) and the same could be true for cascade delete.


Prabodh SPrabodh S
Thank you very much Andrew,

I think I can make use of nillable property.

In both the case it'll work for me. I need to make sure that if it is required(also in case of lookup) then the field should not be empty while inserting record.

Regards,
Prabodh