 Hello friends. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So in this video, I'm going to demonstrate how you can call Lightning Flow to Apex. Before starting, if you want to watch more videos related to Salesforce, so you can go to description of this video. There you will find various links related to Salesforce playlist, so you can follow them. So now, first I'm going to explain the Lightning Flow that I created and then we will go with Apex code. So this is a simple flow where I created two variables. So first one is record ID. Its username is record ID and it is available for input and its type is text. So from Apex, this variable will be receiving a record ID that we are going to use. Then another variable is opportunity stays. It is also type text and it will be available for output. So we can fetch this variable into Apex so that we can receive output. And this is get record element. So it is querying the opportunity based on this record ID that will be passed from the Apex. And I'm fetching the opportunity stays name and it will be stored in this opportunity stays variable. So what we are going to do in this video, a record ID of a particular opportunity record will be passed through Apex into this Lightning Flow. This flow will query that record and it will return the current opportunity stays pick list value back to the Apex. So this is a simple example through which you can understand how we can call Lightning Flow through Apex. So now here you can see this is a simple Apex code which I written on anonymous Apex. So first I created a parent that is map of string object. Then I put a record ID as key and this is the value. So right now I hard coded the record ID of this opportunity record for demonstration purpose when you will be using this in your real scenario. So you will be passing this through a variable, then a flow dot interview dot. So this is the API name of the flow. Then I created instance of the flow through this new and I passed params as the parameter. So whatever input you want to pass into flow, you can set that into a map using params.put. So the map name is params. That's why we are using params.put. If you have one more or another inputs, so you can put them one by one. Then through this instance, you can start the flow. Remember that you can use only auto launch flow in this case because screen flow will be of no use because we are executing this from the back end. And after this start, the flow will be completing its execution and we can fetch the variables whose availability outside the flow is set as available for output. Right. So here you can see I have used that variable of stage through this instance, fat opportunity stage dot get variable value. So this variable value will be typecasted into string and it will be stored into return. And through the system dot debug, we can display it so that we can check whether the exit value is returned or not. So here you can see the stage is negotiation slash review. So now I'm going to execute this so that we can check the result. So I'm executing the highlighted code. So it is executed now I'm opening this through debug. So now if I click on debug only so here you can see flow return negotiation review. So this way this output is available here in front of you. So this way I hope you understood how I called lightning auto launch flow through apex and how I provided input and how I received output from the flow. So this way I hope you understood whatever I demonstrated in this video related to how to call lightning flow through apex. So use this in your projects or assignments. And if you want to watch more Salesforce training videos, you can go to description of this video where you will find all the links of Salesforce related playlist. So you can follow them. Thank you for watching this video.