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
€48.10
List Price:  €67.35
You save:  €19.24
£39.88
List Price:  £55.83
You save:  £15.95
CA$71.97
List Price:  CA$100.76
You save:  CA$28.79
A$80.16
List Price:  A$112.23
You save:  A$32.07
S$67.96
List Price:  S$95.14
You save:  S$27.18
HK$388.27
List Price:  HK$543.62
You save:  HK$155.34
CHF 45.02
List Price:  CHF 63.04
You save:  CHF 18.01
NOK kr569.59
List Price:  NOK kr797.48
You save:  NOK kr227.88
DKK kr358.90
List Price:  DKK kr502.49
You save:  DKK kr143.58
NZ$88.63
List Price:  NZ$124.10
You save:  NZ$35.46
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.45
৳5,972.19
List Price:  ৳8,361.55
You save:  ৳2,389.35
₹4,258.89
List Price:  ₹5,962.79
You save:  ₹1,703.89
RM224.30
List Price:  RM314.04
You save:  RM89.74
₦77,378.02
List Price:  ₦108,335.42
You save:  ₦30,957.40
₨13,924.71
List Price:  ₨19,495.71
You save:  ₨5,570.99
฿1,707.62
List Price:  ฿2,390.81
You save:  ฿683.18
₺1,762.36
List Price:  ₺2,467.44
You save:  ₺705.08
B$310.08
List Price:  B$434.14
You save:  B$124.06
R926.14
List Price:  R1,296.68
You save:  R370.53
Лв94.05
List Price:  Лв131.68
You save:  Лв37.62
₩72,995.06
List Price:  ₩102,198.93
You save:  ₩29,203.86
₪183.24
List Price:  ₪256.56
You save:  ₪73.31
₱2,921.84
List Price:  ₱4,090.81
You save:  ₱1,168.96
¥7,853.11
List Price:  ¥10,994.99
You save:  ¥3,141.87
MX$1,006.35
List Price:  MX$1,408.98
You save:  MX$402.62
QR182.19
List Price:  QR255.09
You save:  QR72.89
P691.26
List Price:  P967.82
You save:  P276.56
KSh6,461.20
List Price:  KSh9,046.20
You save:  KSh2,585
E£2,544.49
List Price:  E£3,562.49
You save:  E£1,018
ብር6,361.91
List Price:  ብር8,907.19
You save:  ብር2,545.27
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$49,514.09
List Price:  CLP$69,323.69
You save:  CLP$19,809.60
CN¥364.84
List Price:  CN¥510.80
You save:  CN¥145.96
RD$3,032.23
List Price:  RD$4,245.36
You save:  RD$1,213.13
DA6,760.37
List Price:  DA9,465.07
You save:  DA2,704.69
FJ$115.98
List Price:  FJ$162.39
You save:  FJ$46.40
Q385.05
List Price:  Q539.11
You save:  Q154.05
GY$10,455.66
List Price:  GY$14,638.77
You save:  GY$4,183.10
ISK kr6,980.10
List Price:  ISK kr9,772.70
You save:  ISK kr2,792.60
DH502.81
List Price:  DH703.98
You save:  DH201.16
L922.32
List Price:  L1,291.33
You save:  L369
ден2,959.81
List Price:  ден4,143.97
You save:  ден1,184.16
MOP$399.96
List Price:  MOP$559.97
You save:  MOP$160.01
N$920.98
List Price:  N$1,289.45
You save:  N$368.46
C$1,839.04
List Price:  C$2,574.80
You save:  C$735.76
रु6,810.12
List Price:  रु9,534.71
You save:  रु2,724.59
S/186.41
List Price:  S/260.99
You save:  S/74.57
K202.74
List Price:  K283.85
You save:  K81.11
SAR187.78
List Price:  SAR262.91
You save:  SAR75.12
ZK1,383.10
List Price:  ZK1,936.45
You save:  ZK553.35
L239.36
List Price:  L335.12
You save:  L95.76
Kč1,209.95
List Price:  Kč1,694.03
You save:  Kč484.08
Ft19,835.61
List Price:  Ft27,771.44
You save:  Ft7,935.83
SEK kr553.09
List Price:  SEK kr774.38
You save:  SEK kr221.28
ARS$51,277.48
List Price:  ARS$71,792.58
You save:  ARS$20,515.09
Bs346.08
List Price:  Bs484.55
You save:  Bs138.46
COP$219,391.32
List Price:  COP$307,165.41
You save:  COP$87,774.08
₡25,377.51
List Price:  ₡35,530.54
You save:  ₡10,153.03
L1,269.45
List Price:  L1,777.33
You save:  L507.88
₲390,156.27
List Price:  ₲546,250
You save:  ₲156,093.73
$U2,225.52
List Price:  $U3,115.91
You save:  $U890.38
zł205.57
List Price:  zł287.82
You save:  zł82.24
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.