 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 schedule triggered flow. Let's understand the requirement first. So for this schedule trigger flow, the requirement is we need to send emails to the opportunity owner when opportunity is closed one. Or if you want to send the emails to the opportunities where it is closed loss so you can do that as well. So you just need to modify the condition for that. So right now I'm going to show this for closed one only. Then we need to schedule this automation to run on daily basis. So here I jumped to the org and first of all, I'm going to opportunity object and I'm going to create a field so that we can track whether for particular record email is sent or not. So I'm creating a checkbox field. Email sent to honor. So initially it will be false. I'm not placing on the layout. So we will be using this field to track so that whenever we create a flow and flow will be fetching the data. So only those records will be fast. We have this checkbox is unchecked. So I selected schedule triggered flow. So right now I am selecting some random date and time it will run on daily basis. Now we need to choose the object opportunity. So stage equals closed one and email sent to owner equals to false. So if on opportunity stages closed one and this checkbox is unchecked then only this flow will work. So I'm just clicking on done. Now here we need to send the email. So I'm just having the action send email. So here we need to have body and subject and recipient email address. So here we need to have the addresses in form of collection. So instead of using this, let's try email alert. Okay, here we need to send the code ID. So in place of send email action I'm going to use email alert. So for that we need to use email template and email. We need to create email template and email alert. So here I'm going to I'm creating this email template. We need to send it to owner. So hi and here we can select opportunity. So we will be having opportunity fields here we can select owner name owner first name I'm copying this pasting it to opportunity is successfully closed one. Now here if you want to place the record link so that is also possible. So you can just have detailed link then copy and paste it here. Right. So in the mail opportunity link will be available. And I'm just clicking on save. Now I need to create an alert. We will be using it in flow. So here I'm choosing object as contact. Then from here I need to choose the email template. So this is the one which we created right now. And here I am selecting owner. Okay, sorry, instead of contact, we need to choose opportunity. So here I need to choose the opportunity owner. And then I need to click on save. Right. So this way this email alert is created. Now I'm just refreshing. Okay, so before I just need to save it to opportunity owner clicking on save. So now I'm going to refresh it so that I can use that email alert action. So here from type unit to select email alert. So here we have this email alert for okay I just incorrectly named it. Actually it is for opportunity. So I just need to modify this. So labeling it as email alert. Now here I need to pass dollar record ID. So this way if you check the entry condition so all those opportunities will be queried where stage name is closed form. And this checkbox email sent to owner is false. Right. And email will be sent to the owner. So this way. Now you just need to save it and if you activate this flow. So at particular date and time this flow will run and you will receive like opportunity owner will be receiving the emails. Right. Run it on the daily basis so daily whatever opportunities are closed one. So those opportunity owners will be receiving the email. Right. Now after this you just need to do one more thing you need to update opportunity and you need to update the field. That is email sent to owner so you need to set it through. Once it is set it once it is set as true. So it means the opportunities which are closed one. So for those you already send the email. Next time. Like we are running it on daily basis so on next schedule run based on this condition, the those records where email is already being sent. These records won't be queried because now on those records emails and to owner field is true. Right. So this is important piece here. Now you can just finally now you can save and activate this flow and you can just check it so I'm no I'm not activating I need to set the date and time as well so here. I'm going to modify this record so that I can have the last modified date and time. So it is 11 one so here in the flow. I'm setting it to 11 three. And clicking on done save. And I'm activating it. So I'm moving to opportunities and here all opportunities. Now I'm just sorting it on stage. So here you can see we have lots of closed one opportunities so I think they are 24 in numbers starting from 33 to 51. And we have that field emails and to owner so I'm having that as well in the list view. So right now it is false for every record. Now if we see the schedule job. So here this sent email to opportunity owner this flow schedule it was scheduled on 11 to it will run at 11 three. So I'm just doing a refresh so that we can check whether execution started or not so it is not. It is executed so on closed one opportunities you will see this checkbox will be checked and whoever is the owner of those opportunities that owner will be receiving the email. Next day if you have more opportunities those are having stays as closed one. So this flow will run again on same time, and those opportunity records will be processed. So, again, I'm going to refresh it. It's executed. I'm going to refresh this as well. So I am just sorting it. So you can see only those opportunity records where stages closed one there you can see this email sent to owner checkbox is checked. Right. And if I go to the email because I'm the owner of those opportunities so here you can see I receive these number of emails. Right. And if I open any record so here you can see my name is available because I'm the owner Sanjay and this is the record link. Right. So this way you can create a schedule triggered flow so that you can send emails to opportunity owner wherever opportunities closed one and you can also run that on daily basis.