Trigger to Count records in self relationship salesforce

0 votes
I am working on one scenario.

I have an object called "Property_Assignment__c" which has two record types. 1) Primary Property Assignment 2) Secondary Property Assignment Its also having a self lookup relationship and this lookup field "Primary_Assignemnt__c" is available on "Secondary Property Assignment" page layout which is lookup to "Primary Property Assignment". Now if I create any records in "Secondary Property Assignment" record type then I need to count and save in "Number_Of__Dependents" field in "Primary Property Assignment".

How can this problem be solved?
Mar 9, 2022 in SalesForce by surbhi
• 3,820 points
1,801 views