 Hello friends, I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate you how you can create roll-ups on the field in case of faster detailization in Salesforce Lightning. If you want to follow Salesforce training videos, you can search my name Sanjay Gupta on YouTube and you can follow my YouTube channel. So now coming on to the topic, in my previous video, I created two fields. One was lookup and another was master detail. So you need to first understand a roll-up summary field can be created on master detail relationship and on master object, that is your parent object. So let's first check for lookup whether on student roll-up summary field will be available or not. So in object manager, I am searching for the student object, clicking on field and relationship and then trying to create new field. So here you can see this roll-up summary field is not available here because we are having only lookup relationship. Now if we go to master detail part, so here master object is book. So we can create roll-up summary field on book object that will be rolling up details of book history object. So now I am going to search for book. So if I click on new, you can see roll-up summary field is activated here. And if we read the description, so it says it is a read-only field that displays the sum, minimum or maximum value of a field in a related list. So related list means the detail object or the record count of all related, all records listed in a related list. So it can perform four operations, sum, minimum, maximum and counting. So now I am clicking on next so that we can create roll-up summary field. So label is record count, clicking on next. So here you can see master object is book. Then we need to select the summarized object. So one master object can have multiple summarized objects. So you need to select the one for which you want to apply this roll-up summary. Then you need to select roll-up type. So here four types are available. If you select only count, then you don't have to select any field for aggregation. If you select sum in max, then you need to select a field that will be available on the child or detail object so that you can apply sum in our max. Then further filter criteria is available. So two options are there. If you select all records should be included in the calculation, then it will include all child objects, sorry, child records. Then if you select second option, so here you can see you can apply filter criteria and based on this filter criteria, the records will be available for the roll-up summary. So for demonstration purpose, I am selecting all records that should be included in the calculation. Then clicking on next, roll-up summary field will be visible for all the profiles and you can see read only is by default check. So this field will be visible in form of read only. We cannot edit roll-up summary. So it is calculated automatically based on the child object. Then we want to place this on the layout so I am leaving it as it is and clicking on save. So this way roll-up summary field is created on book object. So you can see it here it is. The label is record count. API name is record underscore count underscore underscore c. Data type is roll-up summary and it is counting book history objects. Book history object records. Now I am opening an app that is my university in new tab. So in this university application, we have book as well as book histories. So now I am going to create new book. Let's say book name is Java. I am not filling other information and clicking on save. So here you can see record count field is available. That is roll-up summary field. Right now it is zero because no book history record is related. Now I am going to create book history. So let's say I am creating one. This way I created one book history. Now I am moving into detail. So still you can see record count is zero. So we need to refresh it. So I am refreshing the page so that roll-up summary can be calculated again. Now if you move down, you can see record count is one. Right. So this way if you create one more click on save again do a refresh. So here you can see record count is now two. So this way roll-up summary field work. So now I am going to create one more roll-up summary field on book object. So that we can understand how we can aggregate a particular field. So we are going to calculate total amount. Summary object will be again book histories. Now I am selecting sum and field that we are going to aggregate as issue amount. Right. And I am going to include all the records for calculations of us. Then I am clicking on next. It will be visible for all the profiles and read only. It should be available on the page layout. Then I am clicking on save. Now moving on to the book object record doing a refresh. So that field will be available here with the label total amount. And it will calculate amount of the issue amount field that is available on the child side. So let's just create a new record. So you can see it is available. So you need to do multiple refreshes if it is not available. So total amount is available here. Now through related I can create book history records. I am entering 200 as issue amount clicking on save and moving to details and doing a refresh. So it will automatically update roll-up summary field on the parent. So here you can see total amount is 200. If we create one more and this time if I enter 300 click on save moving to details doing a refresh. So you can see total amount is 500. So this way you can create roll-up summary field on parent object that will roll up all the records for some of the records as per the filter criteria based on counting some maximum and minimum. So this way you can implement it. Now I am opening the existing record. Here you can also see total amount is available and total is 300 because here we also created two records of book history. So for this one issue amount is 200. If we move back open this one issue amount is 100. So that's why this book number seven record is containing book amount as issue amount total issue amount is 300 and record count is two. So this way roll-up summary works. I hope you understood how we can create roll-up summary field on the master object in case of a master detail relationship only it is not available on lookup relationship. So if you want to follow Salesforce training videos you can search my name on YouTube and follow my channel. Thank you for watching this video.