 Hello everyone. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate a scenario based on record. Let's understand the record type check scenario that I'm going to implement with the help of record trigger flow. So in this demonstration, I will be explaining how you can apply the record type check. So the scenario is we need to create two record types named as partner case and customer case on case object. Now, after creation of any case record, we need to count like how many partner cases and how many customer cases are related to particular account. And that counting we need to populate into two separate custom fields. Those will be available on the account record. So first of all, I'm going to create two record types, partner case and customer case. So jumping into developer edition org and here in the object manager, we need to search for case object. And here under record type, you can create new record types. So whenever you want to create the part type on case, so you need to create a support process as well because in case of case object, the status pick list is basically controlled with the help of support process. So I'm going to create a support process first. So here you can see the status field pick list values are available new working escalated and closed. So I'm just having all those and clicking on save. So this support process is created. Now, if we go to case object, so we will be able to create the record types on case properly. So I'm just clicking on new. Now here you can see we need to provide the record type label. So, naming it as partner case and support process, then make available for all the profiles, then we need to select the layout. So layout I'm keeping as case layout, then save and new so that you can create one more record type. So this time record type label is customer case record type name is customer case support process. I'm choosing case support process, then available for all the profiles, clicking on next, then case layout, and this time I'm clicking on save. So this way to record types are created on case object. One is customer case and one is partner case. So we need to jump to account object. And we need to create two fields. So I'm going to create first field as of type number. So total partner cases, clicking on next visible to all the profiles. Again, clicking on next available on all the page layouts and clicking on save. So total partner cases field is created. I'm going to create one more field and its label will be total customer cases. Clicking on next visible to all the profiles next and save. So this way to record types and two custom fields are created. Now it's time to jump to flow so that we can create automation so I'm just selecting record trigger flow. Now here we need to select the object as case because on case creation, we need to update the custom fields those are available on the account record. So a record is created and here we need to apply the condition so condition I'm keeping like account ID is null false. So it means if case is related to any account then only we need to run the flow. And from these two options I'm selecting actions and related record, because this flow will be initiated on case creation but it will be updating the account record. So I just clicked on done. Now here I need to apply a report type check so let's first have a decision and inside this decision like we can have a report dot report type. So here you can see we have report type ID option. Okay, so we need to compare this report type ID with particular report type that we created on case, but we cannot manually, or we cannot hardcore the record ID report type ID here because if you deploy this flow from one org to another org so in that case record type ID will be changed. Right, so what we need to do instead of hard coding report type ID, we need to get record type with the help of get record element. So first we need to get partner case record type so here you need to search for record type so report type is basically an object. So whenever you create any report type so report type information will be available with this report type object. Now here you can search for developer name. Developer name is similar to API name for the record types. So now you just need to go to object manager search for case and from report types you can just copy the developer name so if you open. I just need to open the partner case report type. So here you can see this is the record type developer name so I just copied it and I'm pasting it here. Then only the first record and automatically store all the fields that I'm clicking on done. So this way I just got the partner case information. Now I'm just going to use it one more time so that we can have customer case report type as well. So we need to apply the same steps we need to choose a record type object here we need to use the developer name equals. Then this time I need to select customer case and it's developer name. So I'm putting it here. And everything will be same. Now I clicked on done. So this way we have both the record type information. Now I can apply the decision. Check report type. Right. So here. I'm writing partner case. So in case of record type sorry in case of record trigger flow, all the information of a particular record through which that record trigger flow is initiated is available in this dollar record variable. So from here you can just search for record type ID equals and then you can search for this get partner case. So this get partner case record type and then dot ID so it will give you the ID. Right. Then you can have one more outcome. So it will be customer case. And here also you can write report dot report type ID equals. And this time you need to select get customer case record type dot ID. So this way we have applied the record type checks. So we have these two outcomes. So I'm just going to implement the partner case outcome first. So here what I need to do I need to fetch all the cases. And then I will be counting their number and I will be updating the related account. So here I'm going to use get record. So get partner cases object is case. And we are account ID equals dollar record dot account ID. So the account sorry the case record which you created it is related to particular account. Right. So now we are getting all the cases which are related to that particular account. And those information will be available in this get partner cases. And we need to fetch all the records and click on done. Now we need to create a new resource. This is a variable count. So it's data type is number. And the rest of the things I'm keeping as is and here I'm going to use assignment variable. So we need to calculate partner cases count and we need to store that into counter variable. So here we can have equals count and get partner cases. So whatever record whatever number of reports are available in this partner cases. So that will be counted and it will be available in this count variable. Now after this we need to have one update record element because we need to update the related account. So update account. And here we need to choose the second option. Sorry, we need to choose this third option. And here I'm choosing account as an object. Now which account we need to update. So I'm just matching ID equals dollar report dot account ID. So the newly created cases having account ID populated so that account ID matches whichever account record that account we need to update. And here we have these fields like total partner cases and we need to assign count here. So this way the related account will be updated with the latest counting of the partner cases accounts. Now same steps I need to apply here for customer case. Right so I'm just having. Okay what I can do I can just copy this and I can paste it here. And I'm going to change everything so get customer cases. So this is the case object account ID this will be same. Okay one more thing we need to apply. So if we are on partner case so here we need to apply report type check as well. So we are just getting cases so actually what will happen it will fetch all the cases related to that account, but we need to fetch the cases where report type is partner case. So we need to search for report type ID equals and then get partner cases dot report type ID right so this you need to add here and here as well. In this we need to select this customer case and it's record type ID. And rest of the things will remain same. Then I'm copying this assignment element as well, pasting it here. So here we need to calculate customer cases count equals count and get. So here we need to have get customer cases done. And I'm copying this element and pasting it here. So this will be same the thing we need to change is total customer cases. And this way this flow is implemented in front of you. Right, so this is the flow. Now it's time to save this flow and do a test. So I'm naming it as count cases on account and clicking on save. Now I'm activating this. So if I go to any account. So I'm opening this account record and okay in on this account we already have cases so let me open the account where there is no case so there is zero cases and if I go to details. So here you can see we have total partner cases and total customer cases which is blank right now. Now I'm going to create related cases so I clicked on new. You can see we have this option partner case and customer case apartheid, and it is related to this account. Then I'm putting case or is on status as new and I'm clicking on save. So one partner case is created. And if I go to the details and do a refresh. You can see total partner cases is having a value as one. Now again I'm going to related list, and I'm going to create one more case. So this time I'm creating customer case. Click on save. And let's create one more case as partner case. So now two partner cases and one customer cases available. And if I do a refresh. So you will see the updated values. You can see total partner cases are two and total customer cases are one. So this way you can apply report type check in report trigger flow as per the requirement. So I demonstrated it for case object but in real time scenario, you can apply this report type check for any type of object. And if you remember like whenever you need to apply report type check so you need to first get the report type because you can't hard code report ID because it changes orb to orb, but developer name will be same for all the orgs. So this way, I hope you understood how we can apply report type check and report trigger flow.