Skip to main content
Hi Folks, I am new to salesforce and wolud like to know, "How to calculate no of child records to a parent object without using trigger". 

Any help will be appreciated, Thank you very much beforehand.
8 respuestas
  1. 24 jun 2019, 7:43 a.m.

    Case 1: If the Relationship is Master-Detail:

           Then you can create a custom field with Roll-Up Summary on the Parent object and select the roll-up type as Count.

    Case 2: If the Relationship is Lookup:

            Then we have to write the Trigger.

    Case 3: You can use the subquery or Relationship Query as below:

    SOQL for two standard objects. Let’s say Account as a parent object and Contact as a child object.

    Query to fetch the all Contact which is associated with Account ‘Account1’.

    // When a record is fetched from Contact

    SELECT Name, Account.Name FROM Contact where Account.Name = 'Account1'

    // When a record is fetched from Account.

    // Contacts is a child relationship name of Contact object.

    SELECT Name, (SELECT Name FROM Contacts) FROM Account where Name = 'Account1'