Control flow execution with if - else

Salesforce Development Using Apex Control flow execution with if - else
20 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.41
List Price:  €64.99
You save:  €18.57
£39.85
List Price:  £55.80
You save:  £15.94
CA$68.38
List Price:  CA$95.74
You save:  CA$27.36
A$75.69
List Price:  A$105.97
You save:  A$30.28
S$67.65
List Price:  S$94.71
You save:  S$27.06
HK$390.96
List Price:  HK$547.38
You save:  HK$156.41
CHF 45.35
List Price:  CHF 63.50
You save:  CHF 18.14
NOK kr542.95
List Price:  NOK kr760.18
You save:  NOK kr217.22
DKK kr346.22
List Price:  DKK kr484.74
You save:  DKK kr138.51
NZ$83.20
List Price:  NZ$116.49
You save:  NZ$33.28
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,484.79
List Price:  ৳7,679.15
You save:  ৳2,194.35
₹4,174.22
List Price:  ₹5,844.24
You save:  ₹1,670.02
RM236.85
List Price:  RM331.61
You save:  RM94.76
₦61,737.65
List Price:  ₦86,437.65
You save:  ₦24,700
₨13,903.63
List Price:  ₨19,466.20
You save:  ₨5,562.56
฿1,842.69
List Price:  ฿2,579.91
You save:  ฿737.22
₺1,612.90
List Price:  ₺2,258.19
You save:  ₺645.29
B$253.75
List Price:  B$355.28
You save:  B$101.52
R922.13
List Price:  R1,291.06
You save:  R368.92
Лв90.85
List Price:  Лв127.20
You save:  Лв36.34
₩67,969.88
List Price:  ₩95,163.27
You save:  ₩27,193.39
₪185.94
List Price:  ₪260.34
You save:  ₪74.39
₱2,861.35
List Price:  ₱4,006.12
You save:  ₱1,144.77
¥7,722.34
List Price:  ¥10,811.89
You save:  ¥3,089.55
MX$843.21
List Price:  MX$1,180.56
You save:  MX$337.35
QR182.28
List Price:  QR255.22
You save:  QR72.93
P678.57
List Price:  P950.05
You save:  P271.48
KSh6,648.67
List Price:  KSh9,308.67
You save:  KSh2,660
E£2,385.52
List Price:  E£3,339.92
You save:  E£954.40
ብር2,869.28
List Price:  ብር4,017.22
You save:  ብር1,147.94
Kz41,825.96
List Price:  Kz58,559.69
You save:  Kz16,733.73
CLP$46,485.20
List Price:  CLP$65,083
You save:  CLP$18,597.80
CN¥354.33
List Price:  CN¥496.09
You save:  CN¥141.76
RD$2,899.21
List Price:  RD$4,059.13
You save:  RD$1,159.91
DA6,716.85
List Price:  DA9,404.13
You save:  DA2,687.28
FJ$112.23
List Price:  FJ$157.14
You save:  FJ$44.90
Q388.45
List Price:  Q543.86
You save:  Q155.41
GY$10,455.72
List Price:  GY$14,638.84
You save:  GY$4,183.12
ISK kr6,977.10
List Price:  ISK kr9,768.50
You save:  ISK kr2,791.40
DH500.96
List Price:  DH701.39
You save:  DH200.42
L885.56
List Price:  L1,239.86
You save:  L354.29
ден2,861.59
List Price:  ден4,006.46
You save:  ден1,144.86
MOP$402.29
List Price:  MOP$563.24
You save:  MOP$160.94
N$920.44
List Price:  N$1,288.69
You save:  N$368.25
C$1,839.55
List Price:  C$2,575.52
You save:  C$735.96
रु6,679.37
List Price:  रु9,351.66
You save:  रु2,672.28
S/186.27
List Price:  S/260.79
You save:  S/74.52
K193.32
List Price:  K270.67
You save:  K77.34
SAR187.48
List Price:  SAR262.50
You save:  SAR75.01
ZK1,358.11
List Price:  ZK1,901.47
You save:  ZK543.35
L231.01
List Price:  L323.43
You save:  L92.42
Kč1,161.35
List Price:  Kč1,625.98
You save:  Kč464.63
Ft18,056.25
List Price:  Ft25,280.20
You save:  Ft7,223.94
SEK kr542.25
List Price:  SEK kr759.20
You save:  SEK kr216.94
ARS$44,003.90
List Price:  ARS$61,608.98
You save:  ARS$17,605.08
Bs345.36
List Price:  Bs483.53
You save:  Bs138.17
COP$195,270.45
List Price:  COP$273,394.26
You save:  COP$78,123.80
₡25,568.20
List Price:  ₡35,797.53
You save:  ₡10,229.32
L1,234.61
List Price:  L1,728.55
You save:  L493.94
₲373,712.67
List Price:  ₲523,227.64
You save:  ₲149,514.97
$U1,909.55
List Price:  $U2,673.53
You save:  $U763.97
zł200.30
List Price:  zł280.44
You save:  zł80.13
Already have an account? Log In

Transcript

Hello. So now I'm going to show you the flow of education on how I can control. So now, you can see this document, I have written some kind of code here. If you see if this is my logic or my epics program, I can say this program, what are we writing? So six lines of code. So now if I have these six lines of code, how this is going to be executed in the system?

Let me make one small diagram for you. Okay, so if I go here, let's consider this is the sixth line of code I heard here. Okay. So just think this is my six lines of code. Let me remove this final part also. The my number as you can usually do something like this, I have my two lines of code, okay.

But now, whenever this ignition happens, whenever I'm going to execute This piece of this piece of code on the system, how this ignition happens in the system. So now, this piece of code, whatever I have written here, it is executed by my axon time engine. But there is something going on Tammy, we know that only about our bodies that don't do what to make you understand what I'm saying that later on I mean, you can see there is a song or song somewhere somebody on my system, who's exhibiting mine logic or my program, how do we have written which we have stored on my metadata server. So now what I can always remember the program whatever 10 always my program runs like this, it will read my statement, the statement ignition complete, then go to next statement. Okay, let's complete then go to next like this it will execute always line by line.

So what happened? Always mind ignition happens line by line. In normal flow. Always remember Listen happens line by line. So complete online then go to next line then go to next line like this. So each line is going to be processed one by one.

Mallika don't import any control statement anything whatever the logic was going to write it will execute one by one let's consider conditionally what I want I do not want to export these two lines of code okay if in a particular condition okay or it may happen, see I want okay my ignition should continue like this but I want to do some calm till these then do not execute these two statements based on a condition then continued I just want these two statements and use them to be stopped. Okay. So based on some conditions, and also sometimes I may need okay. We have these two four different a statement Let me see this two statements I want to run 10 times in my system I want to run 10 times okay. So, that means normal flow of a juicer and always line by line, but I want to control these two lines to execute repeatedly to execute again and again okay.

So, are some statements I want to skip I do not want to execute that at all for a particular condition. So, even when we want to control the flow of the execution, so when I say I want to control the flow of admission, which usually happens line by line, what I want to control how we can control to control any flow authentication, okay, what you can do, you have equals condition, we can write some details, we can use the switch statement on so we can use the looping statement also. Okay, so we there's nothing more to say okay. If my particular condition satisfies, then execute these two statements, that time I can use my equals condition else do something else. Like, if I say, if you joined by seven, then we'll start the system core to our equal join our 715. We may stop this is on that day.

Okay. So if else if you practice this question, then in the next lesson, I will tell you some other other advanced examples else. I will skip this topic. Okay. So that's conditionally, I'm going to execute something how you do in the real world, if this condition satisfied then I will do some x activity or otherwise, I will do some more activity. Same way in the system.

Only one, the illusion goes one by one and you want Okay, this statement will exit code for a particular condition and other statements is going to do good if this conditional order dispatch, whenever you want that kind of thing. We can use equals statement. There's our starting with a How am I going to do using of my events? And when I'm saying to use my email for I can do this is the very basic of email and if you have seen anytime any problem definitely will get if else statement at least in every class, okay many equals admin you will get okay. So, whenever you are going to write details, what do you do? If then what is your condition to satisfy the condition satisfied?

What do you need to do that we can specify here then this is nothing but your statements to execute on satisfying this condition. So, if you save a significant basic example, everyone is ok. If you complete the certificate sense, then only your company is going to reimburse your admission fee. If not, then you have to pay from your pocket. That's nothing but we can say this two acres flow. Okay, is this.

Okay? So now when I say the sequence is exhibit the statement scheduled on nor satisfying the condition. Okay? So very persistent. Okay, we'll see how much complexity we can make this enables. Let's see, I just want to check something here on my web developer console, I'll try to use how I'm going to use events.

Okay. So let's see, I have one integer variable. Let's see, I say my count, I define my counter Colton. And the metaphysical jungles are not connecting yourself. So that is nothing. So I was just wanting you to understand these concepts.

Then we'll see how we are going to play with my data or how I'm going to do something. Okay, let me know if you have any questions below. In the video, any basic questions, you can Feel free completely. Lucas hermanos me anybody? Like Yeah, yeah, no Davis's. Perfect.

Perfect, perfect. Okay, so now what I'm going to do here, all these emails are just going to write to one very basic program. Okay? integer counter Colton. And if I say if my count is 10 Okay, then only I want to do something. Okay, let's see what I'm doing here.

I'm just going to put into one message. Okay. So I say I am in satisfying segment. Okay, registered bunnies. Basically, I did I just initialize showing you, who is actually in the real time unclick no mean of anything, but to make you understand how he falls in the he knew how to write the condition. So if this condition satisfied, then it is going to execute part of what I have been said.

And if you have something with the code in the airport, foil 14 you do, then you can do is is optional, but if you have something to equal in elsewhere, then you can right here or if you don't have any options to go in any options to only activate to do on expert and you don't know. Okay. So let's see I mean else. So if I do this one till the time my count is 10 what I can do, I let me execute. I can show you. I'll show you.

I mean not satisfying segment. Okay, same way. If I update this see expedition to let the I'm just taking here's what I do. Use letter, the time in accounting, what if I say my account value is 89 then what will happen? account actually now is 10 But now, I'm trying to set count equal to 89 then what will happen? This condition is not going to satisfy it then it will it will see after the save, do I have any else statement?

Yes I have a statement I'll include it or if I see the current flow normal flow of use and how it happened, it will include the statement then the next step then you should continue though each issue some line by line, but now when we control these line posts will be executed conditionally okay. So, if this condition satisfied do this all the way do this, we control who is statement to be executed. Whenever my illusion flow is going to deliver this one. I will directly jump to my line number seven was given because up for the if condition northa displaying is identical to anything else. Okay. So like this, you got it.

So This is Molly. So now just yesterday reason that you have to equal to 489. Perfect. Bye. Bye. Nice question.

Okay. So now you see, let's see past Why did this one equal then we'll come to this the only one point I said is one equals two. So that means I'm initializing the hello to here like, so, in any program whenever, whenever you see this go here like in the example whatever I did here integer counter equal 10. When you see one equal to that means what is a thing you have in a right cell that is being assigned to my left side okay. So, in the mean, let me make a very small diagram for you. Okay.

So whenever we wrote the statement, integers count as a root of this much that means what is going to happen This time, so on the user harappan, there will be one memory memory allocated, okay, whose name is going to be as count in the system in the system, you know, heap memory of the application memory, there will be some memory allocation happens to a variable or with a reference name ascom. And whenever I wrote in an SME they go, and I write count equal 10. That means, the if you see one equality symbol, that means, in that count, I'm assigning the value 10. It's like that. But whenever you see, double equal to So, in this statement, that means the 10 value being assigned to count going in double a color that means I'm comparing what is in left and what is in right, are they both same or not?

If you see what is my count, my count is 10. And what is in right at 910 equal to 89. It's wrong. It's not like this. But this means equal to this means assigning Okay and casinos me Yes, thank you perfect knowledge okay. So, now see this is a very small equal statement when we wrote he then satisfying then go here or then go here.

So now let's see, I just want to make a little bit more logic there see if count equal 10 I want to go inside and I want to check okay. So, the number whatever I have, I want to check if it is divisible by two that means I can that means what I want. If this number whatever I have this count whatever I have, is divisible by two then I can send it to a even number or I can save even then equity or goodwill. So simply what I can do, I can see I can divide count by two, you can do quite as many Welcome. Okay, so let's see if it's equal to Juneau. Okay, all everything I just, I just do, okay, then I can do one more thing I can do here, I can print this statement, even though small basics, so how I'm going to make the more statements which is going to be inserted if necessary, okay?

I mean sorry count vital. Okay, let's see, let's I'll tell if my count is less than 50 then I go inside equals less than 50 unit and make more simple example knowledge of the sea individual anything okay? So don't be confused and if my count is less than 10 then our electrical district man, yes, I will check again eat not less than 10 is my account Less than 20 Okay, there is a an symbol I want to check if a count is less than 20 and count is greater than 10. Then I want to record this. See, I'm just going to make my email segment more they're still trying to say what I'm trying to say here I'm trying to say I can nest any level of MC one if contents another Eastman's. If you see this highlighted or it's just a statement, if you see this each contains another if he is I want I can keep one more if statement here.

Okay, so we can have any level of it. You can see any classes there may have any level of advance. See, I can write also the system insane less than five also in this are going to have been here for less than five. This is in 33 less than 10. Okay, so let's see for this and also what if less than 20 then I'll go here, insert elsif less than 20. Okay, see, now you can see this example, I have nested of three issue.

One is contents another day. The second is contents under a form. So, okay, so what I'm trying to say, we can try it, if conditions, any nested levels is not a word, ie my condition satisfied, then go insert and do whatever you want nothing but the accounting lesson 50 I can come insert this motor advantage and insert that again, I can check if there's any if conditions satisfying or not satisfying, then go on a Google document. Okay, so in this case, if I gave count is 10. So password managed checks count less than 50. So maintain counting, what do I do what I have Here, then lesson 50.

So can I say these conditions are displayed? Yes, they will come here, I'll take a complex sentence. No, it's not less than 10 is equal to 10. So I didn't satisfy this condition, so I'm not going to come inside here. Okay, then I will check Congress and it is in is less than 20. Then I'll go inside, on a grid, you can see point a pastor volute, in part is going to happen.

Let me execute it. Okay, so you may come here is a very basic application. See? I'm inside elsif lesson 20. Okay. See, then I have this one statement who is satisfied here?

Okay. Let me just take these two here. For now. That's me cannot tell if I have four three here. What are the statement I like to do? Why are you good?

What are those campaigns? I'll see on the log file here. How are you how this log pile which segments I'm going to see paper. Is that worth it? Um, I am I think I'll see it in I'm inside five one is weird interface. Yes, you'll get this, then you also get d when it's less than 10 Yes.

So what means that is passed it will take here. Let me explain here. So three is less than 50 or not? Yes, this entity then shouldn't come inside of these. So if they come inside of these, then I'm going to print this one first correct. It will print past I mean satisfying.

The nl calm again, there is one more condition. But here it will check again. My count is three. So three less than 10. Yes or no? Yes, three is less than 10.

Then I'll come inside again. Then I will print this one. So past I'm going to get to this one. Okay, then I am going to get to this one for a second time. Okay, then I'll transition so satisfying. Then I will come inside these.

Okay, what can I say? I'm going to get this one also, am I correct? Then my this part constitution computer? Okay, then my else known it was I satisfied econ ism then I'm not going to else then I'm not going to desales also. So totally I'm going to get these two statements Am I correct? any confusion with me?

Yeah okay is it clear or any any question for me it's clear Perfect. Okay, so it's a very each segment you have received normally remember always the intuition starts line by line. Whenever you have an if statement if conditions are display, usually don't go to the next line. If not ignition go to airflow. If there is no as look normal flow and go for the next statement to find the same way. How many so you have everything we'll take we go into Check we'll insert even in this case the paper starting part is going to append.

I'll come here my happiness SMTP is IEP in this one, then my 13 less than 10 no is wrong, then I'll come here I'll come to else part 13 less than 20 years then I print this one like this will flow one by one. Okay. So this is one switch statements, okay. So this is my if statement. So like this, you can write any kind of conditions also inside the else. Also, if you have conditions you can write again if, so, what I'm trying to say here, you can do any level of nested he fails on the program.

Okay. So when you do this, he fails for anybody writing the program in upcoming sessions. Okay. And also, I'll give you a very basic example of twisted

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.