 Hello, friends. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate how you can call Apex class in vocable method through screen flow in Salesforce. So I'm going to use this use case. So I will be creating a new opportunity from a countercard page through screen flow. And I have to add opportunity amount in annual revenue of the account record. So let's say this is the account record and here you can see annual revenue is 1000 and right now it is having one opportunity and its amount is also 1000. So if I create one more opportunity on this account record, so the annual revenue will be having the new amount added to this field. So now first I'm going to tell you how you can create your class that is having invocable method and then I will be using this class into screen flow. So class name is account action. It is having invocable method update account revenue. It is having one parameter as list of ID. So here I'm going to pass opportunity ID. And remember that the parameter should be list type because if it is not of list type then this class will throw an error. And return type should be also list type. So I'm returning list of decimal. So this return value will be the updated annual revenue of the account. Then this is a simple query. I am querying 0th ID opportunity record from the database and that will be stored in opportunity list having account ID and amount that are available on opportunity record. Then querying the account record in this account list. So on opportunity we have linked a particular account. So now I'm going to query that account. So select annual revenue from account where ID equals to opportunity list of 0 dot account ID. So this opportunity list is having one opportunity record on 0th index. From there I'm fetching account ID and based on this I'm fetching the account record that will be stored in this account list. Then I have created list of decimal that is annual revenue list. Then this ACC list 0 dot annual revenue is added with opportunity list 0 dot amount. So the opportunity record amount field value will be added to the related accounts annual revenue. And then I'm applying this dml update account list. Then I'm adding account list 0th record annual revenue value into annual revenue list and I'm returning that so that I can receive this return value into flow and I can use that to display the output. So this way this is invocable method and this is for demonstration purpose. That's why I use this 0th index but in real time you can iterate this over a loop so that if you have multiple IDs then also it will work. So this is Apex class explanation now moving to screen flow. So here I have already created two screens. So first screen is having opportunity name and stays and second is having closed date and amount. And remember here amount is required because we want that opportunity should be having an amount so that we can add it on annual revenue. If it is optional then in your Apex class you need to check that whether it is having some value or not. So you can apply if condition as well if it is having some value that you can add otherwise you can ignore that you can do. And I hope you can create these screens as your own and if you face any problems so you can go to description of this video where you will find a link of playlist that is how to use flow builder in Salesforce. So there I have also demonstrated from the beginning like how we can use these screens or how we can create them. So after creating these screens the values which we are going to receive from the users I am using those to create a coordinated record. So here you can see five values are set. So account ID is equals to record ID. So record ID is a variable that I created here. So record ID is a variable that will be receiving record ID of the account record where this screen flow will be available. So it will fetch input automatically you need to just check this checkbox as true and the remaining variables are used in screen flow. So close date will assign into close date opportunity name into name stays into stays name and amount into amount. And remember that here you need to use this say store opportunity ID in variable. So just after creating the opportunity record this create record element flows the opportunity ID or the record that you are going to create. So I am storing that ID to opportunity ID variable. Now we have opportunity ID that is the opportunity that is created right now. So now we can create an action. So I'm going to create an action. So selecting type epic section. So here you can see account action classes available. So call a picks class to update account annual revenue. So this is the label. Then here you can see we need to pass the input. So here ID is variable is automatically available that is here. So here I'm going to pass that opportunity ID as input. So the opportunity that is created that's ID will be passed. And here if you want to store the output that is returned to this apex class. So here you can create a variable. So here you can see output is all automatically having this number sign. It means you need to create a variable of number type. So I'm going to create a variable. It's API name is return value. And let's say it is off type number decimal places are two clicking on done. So return value will be stored in this variable. So this way it is created. Now I'm going to create one more screen. So in this screen, I'm going to use this display text component. So it will be display screen. So this is a screen name and API and display text. So it will display the message. So latest annual revenue. And here I'm going to fetch this return value table. So it is available here. I'm making it as bold. And if you want to apply any formatting, so you can do that as well and click on done. So apex class will be executed. We are passing opportunity ideas input and updated annual revenue that is on account will be returned and that will be displayed on this screen. Right. So I'm going to save this. So this way two things are implemented. One is class and another one is this screen flow. Now I'm moving to a countercourt. So now you need to place this screen flow on this account report page. So you need to edit the page so that we can place that flow and we can use that. So from left hand side, you can use this flow component that is standard component. So you can drag and drop it and it will be available on the record page and it will give you options so that you can choose which flow you want to place. So here you can see I have three flows. So I'm choosing this one create opportunity report. And here I am choosing this one pass record idea to this variable. So if you don't choose, so the current account report ID will not be passed. So you need to check this checkboxes to then click on save so that that screen flow will be available on the record page. So changes are saved clicking on back. So we will see how that account and well revenue will be updated. So here I'm passing test to as opportunity stage is prospecting. Sorry, I just need to activate this as well. I didn't activate it. So I'm refreshing this again. So always remember whenever you use your lighting flow on record pages, so it should be activated or latest version should be activated. Otherwise, it will show the existing version. So this happened with me. So now you will see amount will be there in second screen. So test two and prospecting. These are opportunity name and stage. Here you can see close date is available. Then amount let's say I'm entering 2000 this time. Clicking on next. So here you can see latest and well revenues 3000 and I already told you the existing one was 1000. So right now you can see 3000 is this automatically updated and it is having two opportunities. So I'm refreshing so that they will be reflected here. So here you can see two opportunities are available. First is having amount as 1000 second as 2000 and total revenue here in highlight panel you can see 3000 and on record you can see 3000 and our screen flow also displayed the output as 3000. So this way I hope you understood how we can call epics in vocable methods in screen flow and how we can use that on record page. And if you want to watch more flow related or Salesforce related videos, so go to description of this video. There you will find various playlist links related to Salesforce videos. So watch them. Thank you for watching this video.