ChildRelationship Class In Salesforce!
The ChildRelationship class is a part of the Schema namespace and contains methods for accessing and understanding the relationship between a parent sObject and its child sObject.
By using this class, developers can gain insights and handle the child relationship with ease.
To retrieve a ChildRelationship object, you can use the getChildRelationship method from the sObject describe result.
This method returns a list of ChildRelationship objects, providing a comprehensive understanding of the child relationships.
ChildRelationship Methods:
1. getChildSObject():
This method returns the token of the child sObject, which represents the sObject that has a foreign key back to the parent sObject.
2. getField():
Returns the token of the field that contains the foreign key back to the parent sObject.
3. getRelationshipName():
Retrieves the name of the relationship between the parent and child sObjects.
4. isCascadeDelete():
This method determines if the child object is deleted when the parent object is deleted. If it returns true, the child object will be deleted as well. Otherwise, it returns false.
5. isDeprecatedAndHidden():
This method is reserved for future use and currently has no implementation.
6. isRestrictedDelete():
Use this method to check if the parent object can be deleted. If it returns true, the parent object cannot be deleted because it is referenced by a child object.
Follow Us