 Hello friends. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video I'm going to demonstrate how we can use assignment, decision, and loop elements in Lightning Flow. For example, I will be calling an auto launch flow using process builder. And the scenario is we have deadline date field on account. So when this deadline date is updated, we need to populate it on close date on related opportunities whose stage is other than closed loss or won. So this scenario I'm going to implement with the help of Lightning Flow and Lightning Process Builder. Before starting, if you want to watch Salesforce training videos, you can search my name Sanjay Gupta on YouTube and you can follow my YouTube channel. Here you can see various playlists related to Salesforce. Another programming languages are available. So you can follow them. Now I'm going to demonstrate this. So I already created deadline date on account. So if you are following this video, so on your account object, you need to create deadline date field as a date. So data type will be date. So I already created it. Now I'm going to create auto launch flow. So in Flow Builder, this is auto launch flow that I already selected. So whenever you are clicking on new flow, there will be two options, screen flow or auto launch flow. So you can select auto launch flow because it will be called through a process builder. Now, first I'm going to create two resources which will be variables. So first is account ID. Its data type is text and it will be available for input. One more resource that is also a variable and this is deadline date. Its data type is date and it's also available for input. So these two variables are flow variables that I'm going to use in process builder for providing input. So whenever I'm going to update account record, so this process builder will be firing and this process builder will pass account ID and deadline date. Those are available on account record to this process builder. Now, first I'm going to use this get record element. So get opportunities. Object is, so from here I chose opportunity object. Now I need to put the condition so on each opportunity we have account ID field. It is lookup to account so it should be equals to account ID that we are going to receive from process builder. Now here I'm going to add two more conditions like stage should not be equals to close lost and stage should not be equals to closed one. So those opportunities will be filtered where account ID will be matching and stays is not equals to close lost or close one. So other than these all opportunities will be filtered. Why so? Because in a requirement it is mentioned stages other than close lost or close one. So we need to update those opportunities only where stages other than close lost or one. Now we need all records. I'm choosing third option because I need to assign all the filtered opportunities in a variable that should that will be record collection and creating that. So it is a variable name is opportunity list. Data type is record. Allow multiple values because it will be holding multiple values. Object is opportunity. So this way all selected opportunities will be stored in this opportunity list record collection variable. It will be having ID. I want close date as well and I'm saving it. So I'm clicking on done. So it is created. Now I can link it. So this get records element will be providing opportunity list. Now I can apply a decision. Check opportunity list size, right? Check size. This source is opportunity list. So if opportunity list is not null then we want to do something otherwise not. So this way I choose this decision. Now I need to implement a loop. So if this decision will be true like opportunity list is not null then this loop will iterate. So iterate loop over opportunity list collection variable is this when this loop will be trading. So we need to choose the direction first to last or last to first. So I'm choosing first to last. Then this iteration will require a loop variable. So I'm creating one more variable whose name is opportunity record. Data type is record. Object will be opportunity. So from opportunity list one by one each record will be available in this opportunity record variable. Right? So I can link it now. So check size. So if size is greater than zero, so we can maybe modify this label. Size is not null. Right? So if this opportunity list size is not null, then this loop will be iterating. Right? Now inside this loop, I need an assignment. Right? So we have this opportunity record. So its close date should be equals to deadline date. So I am modifying this clicking on done. Right? So this loop will iterate. This loop will be iterating on opportunity list that we filtered out. It will give its one by one all record to opportunity record. And here we are assigning deadline date to close date on all opportunity records. Right? Now I am creating one more resource that is a variable and its name is opportunity list to update. Data type is record. It will contain multiple values and it will be related to opportunity. So this way this record is created. Now I need to assign this opportunity record to assign opportunity record to list. Right? And here I am going to choose opportunity list to update. Operator will be add and this opportunity record. Right? And click done. So this will start from here for each item in the collection. Deadline date will be assigned. Then that opportunity record will be added to opportunity record list. And then this will go here. Right? So this way this loop will iterate when this loop will be terminated. We need to update the opportunities. So update opportunities. So here use IDs in all fields from a record or record collection. So I am choosing this one. And opportunity list to update. So this will update all the opportunities. I am clicking done. And after completion of this loop, it will be linked to this. So after last item, this update records will be executed. So this way I implemented this flow. So here you can see I implemented decision loop as well as assignment. So use of assignment, decision loop and lightning flow. You saw here how I implemented them. Now I am going to save it with a new version. So I implemented it in existing flow. So that's why I am saving it as save as activating it. If you are creating it from the beginning, so you just need to click on save and activate. Now I am moving to process builder. So I have one process builder on account. I am cloning it. So here you can see account is selected, which is for record creation or addition, updation. Then I already set this condition like deadline date should not be null. And deadline date is changed should be true. So this is criteria. If it is true, then we need to call the flow. So flow that we need to call is update opportunities. And we need to pass account IDs and deadline dates. So account ID and date will be passed to flow. So this way you can see this process builder is also good to go. I am activating this. So we created a process builder as well as lighting flow. Now moving to opportunity, so moving to account. So I am choosing this account. So here in the related list, you will see five opportunities are available. So here you can see opportunity stage is prospecting, prospecting, prospecting. And for two, close one and close lost. So lost is 25 and three closed it. And here it is 93, right? And others are having 15, 5, 15, 5 and 15, 5. So now I am going to modify deadline date field that is available on account. So remember that I created this custom field in my org. So for demonstration purpose I am using it. If you are following this video, you need to create this field on account object as date type. So here I am choosing 31st five. So as I click on save, so you will see all three opportunities whose stage is prospect, prospecting. Their close date should be now 31st five. So you can see here their dates are modified to 31st five, 31st five and remaining to close lost and close one are 93 and 25 three. So they are not modified. So this way I have flow and process builder working currently. So I hope you understood how we can use decision loop and assignments and lightning clue. So for decision, I choose only true part if you want to choose false part. So you can choose that as well. But right now there is no requirement for that. So that's why I'm not used the false part of the decision. But in your another scenario, you can use that as well. So I hope you understood whatever I demonstrated in this video. If you want to watch more Salesforce training videos, you can search my name Sanjay Gupta on YouTube and you can follow videos playlist. Those are available on my YouTube channel. Thank you for watching this video.