Future Method, Queueable Apex and Trigger Execution flow

Salesforce Development Using Apex Future Method, Queueable Apex and Trigger Execution flow
1 hour 2 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.98
You save:  €18.57
£39.74
List Price:  £55.64
You save:  £15.89
CA$68.36
List Price:  CA$95.72
You save:  CA$27.35
A$75.43
List Price:  A$105.61
You save:  A$30.18
S$67.50
List Price:  S$94.51
You save:  S$27
HK$390.66
List Price:  HK$546.96
You save:  HK$156.29
CHF 45.28
List Price:  CHF 63.39
You save:  CHF 18.11
NOK kr542.32
List Price:  NOK kr759.29
You save:  NOK kr216.97
DKK kr346.21
List Price:  DKK kr484.72
You save:  DKK kr138.51
NZ$83.04
List Price:  NZ$116.27
You save:  NZ$33.22
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,477.48
List Price:  ৳7,668.91
You save:  ৳2,191.43
₹4,173.46
List Price:  ₹5,843.17
You save:  ₹1,669.71
RM236.90
List Price:  RM331.68
You save:  RM94.78
₦61,737.65
List Price:  ₦86,437.65
You save:  ₦24,700
₨13,884.75
List Price:  ₨19,439.77
You save:  ₨5,555.01
฿1,836.53
List Price:  ฿2,571.29
You save:  ฿734.76
₺1,613.79
List Price:  ₺2,259.44
You save:  ₺645.64
B$253.58
List Price:  B$355.04
You save:  B$101.45
R921.65
List Price:  R1,290.39
You save:  R368.73
Лв90.79
List Price:  Лв127.12
You save:  Лв36.32
₩67,757.86
List Price:  ₩94,866.43
You save:  ₩27,108.56
₪187.05
List Price:  ₪261.89
You save:  ₪74.83
₱2,856.96
List Price:  ₱3,999.98
You save:  ₱1,143.01
¥7,687.37
List Price:  ¥10,762.93
You save:  ¥3,075.56
MX$846.40
List Price:  MX$1,185.03
You save:  MX$338.62
QR182.04
List Price:  QR254.87
You save:  QR72.83
P679.94
List Price:  P951.97
You save:  P272.03
KSh6,711.15
List Price:  KSh9,396.15
You save:  KSh2,685
E£2,396.98
List Price:  E£3,355.96
You save:  E£958.98
ብር2,864.89
List Price:  ብር4,011.08
You save:  ብር1,146.18
Kz41,759.31
List Price:  Kz58,466.37
You save:  Kz16,707.06
CLP$47,049.08
List Price:  CLP$65,872.48
You save:  CLP$18,823.40
CN¥353.90
List Price:  CN¥495.49
You save:  CN¥141.59
RD$2,900.17
List Price:  RD$4,060.47
You save:  RD$1,160.30
DA6,724.18
List Price:  DA9,414.39
You save:  DA2,690.21
FJ$112.18
List Price:  FJ$157.07
You save:  FJ$44.88
Q387.94
List Price:  Q543.15
You save:  Q155.20
GY$10,441.17
List Price:  GY$14,618.48
You save:  GY$4,177.30
ISK kr6,976.60
List Price:  ISK kr9,767.80
You save:  ISK kr2,791.20
DH503.40
List Price:  DH704.80
You save:  DH201.40
L884.08
List Price:  L1,237.78
You save:  L353.70
ден2,857.75
List Price:  ден4,001.09
You save:  ден1,143.33
MOP$401.71
List Price:  MOP$562.43
You save:  MOP$160.71
N$923.86
List Price:  N$1,293.49
You save:  N$369.62
C$1,837.28
List Price:  C$2,572.34
You save:  C$735.06
रु6,663.84
List Price:  रु9,329.91
You save:  रु2,666.07
S/186.31
List Price:  S/260.85
You save:  S/74.53
K192.92
List Price:  K270.11
You save:  K77.18
SAR187.49
List Price:  SAR262.50
You save:  SAR75.01
ZK1,346.25
List Price:  ZK1,884.87
You save:  ZK538.61
L230.87
List Price:  L323.24
You save:  L92.36
Kč1,161.41
List Price:  Kč1,626.08
You save:  Kč464.66
Ft18,082.13
List Price:  Ft25,316.43
You save:  Ft7,234.30
SEK kr541.20
List Price:  SEK kr757.73
You save:  SEK kr216.52
ARS$43,928.30
List Price:  ARS$61,503.14
You save:  ARS$17,574.83
Bs345.62
List Price:  Bs483.90
You save:  Bs138.27
COP$194,235.29
List Price:  COP$271,944.94
You save:  COP$77,709.65
₡25,508.30
List Price:  ₡35,713.67
You save:  ₡10,205.36
L1,232.91
List Price:  L1,726.17
You save:  L493.26
₲373,633.39
List Price:  ₲523,116.65
You save:  ₲149,483.25
$U1,909.79
List Price:  $U2,673.86
You save:  $U764.07
zł200.70
List Price:  zł281
You save:  zł80.29
Already have an account? Log In

Transcript

This conference will now be recorded. In the previous session we discussed about to future calls. And now we're going to write a future method. Okay? So that didn't matter, we'll send an email, okay, to some email address, and we'll invoke that on account triggers. Okay.

So in our account, we'll just capture the email address. Okay. And to that email address, we'll just send a plain text email, and how we can go using future method that we'll see. Okay. So now, you could remember, we have already accounted for these symbols, this log. So, whenever I'm going to write it with a method, it should be static.

It should compile and it can take parameter of Anything went up or a collection activity types. Okay. So now, if you remember, let me open that. I'm just going to write one feature method, which is going to invoke in the account triggers. Okay? We have written up on trigger, okay?

And now that logic will invoke from this place. So now what I'm going to do here, I'm going to create a class. And to make the class as a future, we have the huge mind feature. And the reason is for now, let's see I just mentioned here. For example, send email handle your class. I want whenever you want to send an email it is I want to fire a jazz influence operation, which nothing but as a preacher method, so as a pitcher method, I'm going to make it a static event I will be void.

Okay. Then I just send some send email to some email id I just pass parameter as email email id. Okay. For example, I'm just going to pass parameters a list of string. I can take parameters as a collection of community. Let's mention email id list and to all emails.

What I'm going to do here, right now for plaintext, I'm just going to send mine specific message. Let's see. Message subject. Okay, now, I'm going to send in this part we are going to learn how to how we can send the image what other inbuilt methods we have in the Salesforce. Okay, using That will send the email. So as I'm saying, I'm going to make this in a synchronous call.

I'm going to tag it as a future. Okay? And now insert these. Whenever you want to send an email, we have something called single a message. And there are many inbuilt methods to set up a party for direct mail. Whenever you're sending an email asking her to set or in all the emails part of the subject going to be in the email, what is your body going to be assigned to which address or maybe you can give someone a cc or BCC all these things are going to build with this.

So if you see the single limit message, okay, I'm going to the epics all the class here. So here I can see what is the class and what is the method name we have one which we can use. So Salesforce is that is your message that in class we have single email messages. We have used this class to build any kind of email. We Understand this is contest many methods for sending single event message, why not sending the email email according to the email I contain, based on the template what is even vessel for something like email template. If I have some email template, I want to send the email in email templates for you to do using workflow.

If you want to use any template, you can use the template name, get template name or set template. Now we can do it semi cvcc. Other sec address, okay, if I want to add some attachment, okay, what kind of body you want to make? Okay, if somebody replied to that email where you want to tag that photo, just say they're going to replay everything we can use this method provided. Let's see, we'll just write a very basic email for Celtic has to send email we understood okay we have some class called a single email message. So now, I am going to use this class nothing but my single email message.

So this is me, class men. So I have to instantiate this class so that I can set up The property of this class so whenever I think single event message is nothing but coming in the messaging Fs if you want to you can tag messaging Fs messaging.in the label message that I just mentioned in this email messages mine object name. Okay, so now I'm going to instantiate it so this is nothing work I'm just initiate one reference of missing illnesses. So after that, what we will do we have to say what is mind subject, what is mind body and what is meant to address for now, just consider, I'm just going to send to one particular address Okay, so that address we have here, which a pastor which I'll pass for my account will come anyways okay. This method can be used from any place just we can pass parameters, email list and apart subject, I want to pass it on.

Whenever I am going to set the email, body and email address so now to set the email address you see there's a method to call set email address let me show that mean that message like sets the CC and BCC and same way we have set towards debt what are the two are just totally similar this I'm going to say it's in the Senate. So, if you want you want to set CCN which is you can use also tempting set to address I can use this one. So see you can go here and I put set to understand this to address going to take the elements of nothing but my IRA type of element or policeman element to which are this I want this and so this way, so now we understood Okay, we are going to send the email and for that, we said, What is my email address here?

What is my email address? Everything is good enough to address. Okay, so now same way Want to set the subject subject of buying email? See we have something called sale subject. I just read here and I just using that method, but this method of homework in this namespace I have in this method, the classes engraving message method, it says subject. So I want to set subject as what I'm ending as a parameter to my subject.

Okay, so now I said, what it meant to order, what is my subject, okay? Same way I want to send, we can send you like see if you remember when you're doing the workflow emails, we can create email template of HTML type or we can create an email template of plain text. So if you want to have a student estimate type of body, in the email, you can set you set the standard let me show that method. Okay. So we have a certain text, okay. In the same way, we have also satisfied As you can see here, set plain text for you.

If you don't want to send any HTML type of thing, then you just set plenteous for you want to set up limiters for the URL you can call set estimator do what you want right now and just say method I'm just going to use a set plain text. So, this mean email message intelligent method, which we call it here dot set plain text. Now I go here, and now I just pass a parameter What is my body is going to be solaredge publican body here and what we can dynamically build based on our requirement but to be done, okay, so now, I just build it But till now, there was a good question on that. So do we also need to pass a body in the parameter next to message subject? Yes, we can pass on So, let's see that. Okay, so I'm just going to pass you can pass any number of parameters message.

Okay? Now one that also can set here, okay, I just kept the body here. Okay. So now to send an email we always we need to set to whom and sending. What is the subject? What is the body?

So after this much we do then we have to send the email, how is an email? There is a method already we have in the messaging, which you call sentiment that calm on the messaging answers, not in a single even classes or not message. I'm going to save that but Okay, let's see the messaging cells for the Java class which will help us to change the email. Okay, we go to the messaging class. Let me show you the methods that we have. Okay.

We have something called Sandy So you can email me or send me a message, whatever you want, we can use your so right now I'm going to send him. So I know you send email with list opt in email insensitive missing element message. So obtaining emails or single event messages can send in this place. Okay? So now I'm going to use this one. Okay, now I came here.

So what I'm going to do here, here I have an industry is called messaging and the messaging part of the method sending. So in the Send Email, what I'm going to tell you which email I'm going to send, I'm going to say in my email message, who is nothing but a instance of mine single message, okay? The moment I do this, no, it is. Every method can have a container. This is going to return the mails what you are going to send, it's going to be success or not. So I'm going to send multiple images now.

You'll see I'm going here I just build one image, but I can pass multiple images So, whenever doing multiple labels that time also, it will return me which emails have been successfully sent successfully sent or which are not. So to tag that, okay, but they don't have the same email we are getting from here. It doesn't like a database insert or update, we return a result. So here, it returned me standard email result. Okay. So, that class depends which email we successfully able to send or not.

Okay, so privacy messaging.so Why didn't class name my class which is going to return the which is going to hold the result of sending the email, nothing but we call it as though Send Email agent. Get the RF records which successfully sent or not. Okay, so now, the moment I said seeds Whatever any question that I made then that there may be some wrong email address we can tag or maybe we don't have the to address it may give me error okay. So, the image here which is sending its error versus everything we can see on the on this part okay. So, if you want to see all the information about this entity manager is nothing but one another class we have Okay, like he may not ever see me I have one more class which is called machine learning limited. So, here we can like how you manipulate which operation purposes are not in database operations clusters, same way we can do in the Send Email also.

Let me show you how you can get accounts we can see what they are each all the methods have changed and not everything we can see here. Okay, so additional symbol going to give me access or error on this place. So same way How will you do on that I was able to Same way we can do this but also, okay, so here what I'm doing, I'm just going to send, which is going to give me email legend for the success or not that much. So I'm just giving a name. Let's see, I just give the name of the adult. There's nothing.

But whenever I do, let me save you save you. I'll show you what are the error coming right now? Yeah. Okay. So I see. Okay, let me fix all this stuff.

Now. Let me give a comma this interpreters. Okay, if you see here, this Send Email what I have, it is going to take array of single email message method, not a single one. So what we can do here, this, this parameter should be a list type or some array types. Okay, so now, I'm going to build all as a single email message. Okay, this is just one record, but it should be a list of a list of single email message.

Okay, it should be a collection of a collection of emails I can send in a single time. So now I'm doing that this way. It does not work, I create a collection of my single, single email message, okay? So that I pass the parameters. Okay? So it is I'm just sending the email.

Okay, let's see if what I'm going to do here, if we go to the account. Okay, so what is I'm trying to do here in the account trigger, whenever I'm going to create a new account, I will send one email. Okay. So to which email address it is going to pick is going to be the email and let me put some email address here. Okay, so what I'll do here, I'm just going to put email address in some intro creating a new field. I'll just put some in some text field.

Let me create a new email field here. We can Yes we can do any activity here from anywhere you can do and if you if you want in all the minerals so yes, we're not going to do that. But that's that sounds good. So I'll write this logic inside the content Okay, whenever you're going to insert a contact I'll send a email nothing but a welcome email. Awesome. Okay, so I think I don't have any reason the contact let me write a results in contact quickly.

From there, I didn't know so that we can see the end to end how I'm going to conduct Hirsi in this Sunday trigger. I don't know I have already triggered this nice. So I just go here, contact trigger. So after the insert of the contract, I want to send an email. Okay, so now what I do here, I will take all the email addresses whatever I have Okay, so let's see, I'm just looping on his content. Click New.

Okay, so now in the content if you go, let me show you that Phil here, I will copy directly by name from here the contract fails these emails be limited. Okay. So if this email has some value, then I will just process it. So now I did leave my contract, having some email content is not equal to null. Even you can use a string or presence nothing of string is blank or is not blank. Then I want to add a list.

And let's see, I just kept it as email id. I have parameters a list here you can see. So some list of string I'm going to create here, email list, dot are all the email address. In here, contradict me. Okay, so now, this is not a murder list. So I just create one collection of string whose name I gave us email id list equal to new list of string.

Okay, so now I have everything. So once done if my email id is there, okay, ie, email id list or site greater than zero, okay? Then I want to invoke this animal handler. So as it's a static method, because it's the future so directly, I can invoke my Send Email handler, dot send email to email ids. So now here I specify what is my email list? my email list is this one email a list.

Okay. Then I have something called subject and message body in the subject and this receive a Welcome to Let's see hello world. Not Hello lol come to City area. Okay, so let's I mentioned this is my email body and this was I said I just have it so now my contract is ready. Okay see after this, I may have many more logics to insert properly here. Indeed, I may have many more logic cells.

So these operations sending an email if I will just make not as a feature as a synchronous call, it takes some time till the time this email sending not completed. I'm not going to do anything but as I am a teacher, I just invoke these I learned Oh wait, what is going to happen email it's going on audit fail or not. But then I'll continue my all logic whatever. Okay, so this process, I'm just going to run in the bedroom. Okay, this any mail, I'm running in the bedroom, running in background, a synchronous call. Okay, so now I just said that that must think we do.

Okay. So now let's see, I'm just going to create a new content. Again, please message me your email address your country, I just put contact with your email address. We'll see we can the middle. It's India. Okay, I'm gonna determine.

I'm just going to put the similarities you can see the stimulus coming through. Okay. Now if I give this email now I'm going to save it. Okay, so when I did with your name, and I'm going to make one more Okay, and keeping my email addresses Have you got an email? This I got one. Okay, so see this operation completely happened in my in the back end?

How will know if you go to my jobs? Okay, so if you see me all our pictures, then each one email, send email digital what we do that as a future microphone. So you can this animal and I get to contact one with your email this one is my email address. Let me see if we have any student behavior in English or does it work like database dot insert method or insert? That means for partial exemption as I'm coming to there, okay? Okay, my heading objects and everything.

Even you can set dbcc everything. So whenever I'm sending the email we see we have one not single all or nothing. So there is a method or method overloading. Okay. So what happened here? Maximum, then, like, see if he like kept one limit on these other, I don't know dimensioning only one rule.

So like this you can configure 10 emails, Max. Okay, send the list of up to 10 email insensitive with this single email message or mass email message. Okay, so now whoever is sending this email, okay said to save email message object and trigger defend for this Okay. So now out of 10 if something got failed, then do you want to stop all the email to send or you will send which can go even like how you do partial update or partial insert in database operations and also you can do it this parameter all you can pass true or false. Similarly, completely same logic here. Okay.

So what you can do you mean you can actually send email messages, same thing we do here. Okay, here, we'll give them SS IDs. Let me show you one more very important logic here. Since the Santee intuition email based on some email templates, okay, so who is template? What is email template that ID and whenever sending the email templates using email templates that we have set, who ideal body I think what for which objects these email templates are built in, so that more Swedes are going to be populated based on that and to whom you are going to soon. Okay, so that infamous sense of so we can set it is just a future.

So I'm not going to do that but in the messaging messaging logic, so in this way, we can just invoke the future. So this is one approach to have the synchronous code string inference qualified and saying whatever we have, we had the better fix, we had the scheduler. We had my imputation method. Okay. And this is what you see now we have something called a single ensemble, something called pure electrics. Okay, so Let me show you this animal handler is there.

If I want to have another feature called let me quickly create one more feature call. And I want to invoke same feature called am, I want to invoke one more feature called insert this feature. Just quickly, I'm going to create one episode. Let's is a feature called verify, let's say nice repeatable. For example, I give the name as a necessary feature. Okay, so now let's see, I'm just quickly writing another feature.

Publish that studying word. Okay. My future? Not much future. Okay. Let's give you a test measurement.

Future method. I don't pass anything. I'm not adding an interest. I'm trying to invoke it what will happen We'll see. Okay, so now see in this place. I'm just going to invoke once again Mr. Richard Dodd this future method.

Okay. So I'm just going to simply invoke this. Let me see, I'm just going to keep studying. We'll see what happening. Okay, so now I'm just going to create a new contract. See, my other classes got saved.

Now I'm going to create a new bundle once we're done just give me 30 minutes here. I just want to say this, I added the last one. So you see my presents as well done. Let me go to the next job. See, future method cannot be called from a future batch. But my opposition doing stuff but in the spare time isn't mind sending of the email because whenever you do a future call, we cannot invoke one feature call in train said another feature code that means I cannot nest any future from but maybe now you didn't get any record.

So now I'm just moving this this this company in this part okay. So, we understood here we cannot invoke any future call insert another future. So, it can have only one level of future colinas system, so, we cannot have natural future plans. Okay. So, then like now we have another way of writing this kind of a synchronous jobs in unity when epics, okay, so, let me show you what is capable of giving up it's okay So, whenever I'm saying cable effects, it is nothing but another way to write a simple database. So again if you want to write anything that synchronous or you want to run anything as a background operation in another transactions then you can use a synchronous effects okay.

So, whenever you are doing the same thing if anything you have long running process okay like you want to send an email or you want to connect to some relational system or you want to query many records so, you need to process which may consume a lot of time. So, everything we can convert to a table epics, okay, instead of running in the same same transactions. So now whenever you want to write any class as a cable class or cable topics, we have to implement an interface like in the future class we use future annotation. Same way we can use some anatomical cloneable interface is not an addition, some interface use color the cable Okay, so we'll see is going to convert this part completely allocatable and how it's going to happen elsewhere. So that in future if you see any future method and somebody say okay, we'll convert it to a will of x and how we'll do it.

Okay, so I'm going to here again new ups class. So in this new class, I'm just writing the same thing. Send Email handler okay, but instead of this I'm just writing it as in graphics or sending email nothing some other name I give. So this class if you want to have a Google epics, you have to implement a specific interface for the interface. Implement interface name is nothing but doable. Okay.

So this cable is going to help us Let me type nested to you you will. Okay, so this cable and implement, so selfless Dante minion understands, okay, this is different. Switch going to learn in a synchronous mode, okay. So, all the interests will we are not going to go directly we are going to keep in a perspective, if you remember we have something called place queue in a job. So we are going to add it in Netflix queue, okay. So, everything will be in the queue, and one by one rejiggered depending on the resource availability.

So, once I do this one thing, I have implemented an interface, the interface is a sync method. So, there is a method which call execute. So, that method we have to override here, so, I'm just going to write that method it should be void. Okay, then my method name is execute, okay. And this is going to take my parameters payable context like that every batch will contain context here and it's going to have a cable context okay. I just wrote out something Yeah, okay.

Anytime name you can do. So now, I want these to convert. So now for this IRC parameters. So these are the parameters what I owe, I cannot pass it as a parameter here. This methods would be looks like this, then how I can do, I'm, anyhow I need this parameter. So I'm just going to write a constructor here.

So in the constructor, I'll pass it parameters. Let's see. I just give an image image at least the main subject and main body. Okay, so there are many ways you can do this this summer. I'm not going to I'm writing in a very simple way. So here, I'm just going to create one collection.

Okay, so whose name I just give me the list? Okay, I'm going to create one variable Let's see I'll get an image male subject and I'm going to give one name more name which we call Mrs body part a pass as a parameter everything I can say right now here. So, now in this in this way, if you want to pass complete a subject that also you can pass as these parameters that that also you can get in the future method. We if you have a future method you cannot get anything from the a subject or from the list of a subject, but in this part, we can get that list of is calling a subject collection or any specific a subject as these custom parameters. Okay. The nice he I have the similarity, I got my list now.

Okay, then I got my subject. Okay. Nothing but my mail subject. Because I've made myself a cap here, then I can get my message body also. I'm just going to set this very thing here. Okay, so now I got everything, whatever I have.

Now, I'm going to copy this quote completely whatever I am. So if you give different names then you will have to just change the names. Okay? Right now you're seeing them needs to be used. Okay? That's similar at least already I have here.

Message subject nothing but this is my method subject and giving the same name. message body, you can give any name but if you give the same name then if you understand Are you okay? I'm just having it. So now, though, what what I will doing using my Twitter handle, same thing I am now doing on this. I think that we're going to invoke this feature and Lord, I used to call it a class template mechanism. But whenever you are doing cable you are not in Working that methodology instead of that you're going to place it in the queue.

Okay, we'll say name also house viewable. So you are placing in a queue whenever resource available it's going to execute. So now I just met system dot okay. in queue. See we have a classical system integer method. So on this place, what do you want to send?

I want to send I want to trigger my class which is called Send Email addressing let me insensitive so here are instance your data Send Email handle receiving, let's see em any name you can give anybody a thing then you can pass all the parameters whatever parameters I have, email id, my subject, my buddy, okay, so whatever I have parameter here, I just passed here. It's like last year and now this parameter let me save it. So I I just got into consider a password. And this value girl said Then I'm invoking this I do this I do nothing but I googled invoke from the into, into job. Okay. So this integer number, what I'm going to do, I'm going to enter, I'm going to cue mine, I think plus reference name.

The instance I just kept here. I just have no. So see, same thing What are doing in the future? I do? I do do know, let me see what I want to say everything has point I said, whenever I'm going to do this cable, I can pass my s object collection records or any sort of records. I'm not restricted myself to use only primitive type of database or primitive type of primitive collections and not only is suited for that, but I can pass any collections any type of a solid across also.

Okay, let me do the one round of testing. I just work on that. I'm going to create new This I just give some names here. Okay? So I just put in your email address once again, I just click save. So now you will get one email let me show you what happening job job but see one cubelets everything is future now.

Okay, so that cable positioner Okay, now you will get an email. So, let me let me show you here. Let me go and put my email address here. So I'll also get one email right now you can see I got an email here. Okay, so now, the same thing what we hard like I wasn't able to call future into the future. I'm going to use this ending late.

I'm going to Eve I have an hour Another class of passing objects. I'm just going to create another class, I think of x. When do I create a new class, I just give the same code. I'm using this name as new shiny. Well, I'm just keeping the same logic, okay? Something else I'm doing, okay?

I'm just going to invoke these inside this class. Okay, so now see, what are you doing in the future gold. Same thing I'm going to do here now. Okay. So in the contract trigger, how I call I'm just invoking the same thing. I'll just change only my parameters.

Yeah. So this was the class name, nothing but new send email, like proper date. I'm just giving the same name here. Okay, so everything is the same thing. I just have it so now see from this has been recipe I'm going to invoke another asset class I think what one I think most operations can invoke another single operation or similar I can say I can nest I can make nested of a synchronous calls. Let me see, I'm going to clone it I just save it.

This is when this is nothing but mine duplicate rule enabled so we can ignore it. Okay. I save it. And if you see in the main job, what happening See, cable cable fired. There is nothing like in the future methods are failing. It's not so obviously I'll get to email because same thing I'm calling two times.

You know, it goes in just for now. Before I get to now we're gonna go to budget a minute. I got two emails. Okay, so that means I'm just trying to say if you use future then you cannot do it of course, but if you do this cable then you can do necessarily Of course nothing but I can tell you everything in a job so I can do the chaining of jobs. GPUs are similar topics nothing but my cable job, my cable interface, so whenever to the system or in a job. So what happened here?

We just pass which we will class to be exhibited. Okay, there's one that he didn't. Okay, so let's see, for everything we have a best practice and limitations. What is the clearable limit? We'll see how many times we can exclude cable limits on how many channels we can do it. Okay.

So again, remember, maximum p jobs can be placed in a queue if you're doing so in a single time. You can have 50 jobs in a queue. Okay? So if you want to have like you initiate a time zones and you and the inner, your core going to hire more than three times this job, it will tell. I mean, let me do the same thing for you understanding. Okay?

So this part of logic what I'm invoking let's, I'm just as a bad practice, I'm going to show you only for that imagination today. Follow what I should not write it. But to give you the clarity on this example, I'm just going to invoke this class that this call more than 50 times we'll see what happening. I listen. Let's do one. A little creepy vibe.

No, it's certainly a good thing to do. So we'll see what happens. So I'm trying to execute more than 50 names here. Okay. So we'll see what happens one time if you create contact minimum. Now my logic What do you have, it's going to create more than two buttons.

I just click Save. Okay, let's see, we got one limitation too many cubicle jobs at the queue. So I'm going to add 51 jobs in the queue so it's going different. Okay? So pass immediately understood, okay, we can have maximum number of jobs in the queue. Okay.

And the nested what I'm doing from one as in one to one class, or one table job, I'm calling another table job like this, how many I can call maximum you can do pipe Jen. Okay, from one queue to another queue like this maximum pipe, name Pipe down chain, you can make it more than pipe it will not allow. Okay, so if you want to see that like this article, type letters and I'll go one by one, then you can see how it's going to happen. The same way how we do is the same thing. So nothing but three points to remember which, okay, so You can make maximum height change in a cable and 50 jobs can be in a queue for Singleton instance, and we have to implement the cable interface where I have to override my egg method. So what we'll do here, so, if you want to pass any parameter all the parameters you can pass in a constructor and that you can use like in future con, you cannot pass any primitive types any subject or any HR will collisions, but in cable you can pass anything, okay.

So then you can write a logic to persist whatever you want in concrete confusion and unique ocean. So how can we decide that when to use and when to use future? Okay, see future and cable? Do the same thing for me. Okay. So this cable, implement the sun cams.

I think we put together Okay, so we follow that we had only future methods. Okay. So there are many limitations we heard so then shelters camps camps of it this future. So this cable, so if anything we're going to write as a synchronous job like this, close your eyes, right and in a cable. Okay, like workflow and process builder. So if anything you want to do you can right in the process builder instead of workflow.

It's good to use the possible the same way you can use cable you can ignore the future complicated. Okay? So cable nothing about the advance was another future method. Okay, so likewise in future the job's done in background. So similarly incurable as well jobs run in the background in the background, you can see all the Cuban comes here. Okay, so if anything you want to see just you can come to monitor under that you can see a background job like fescue, anything, okay.

So everything again, you can see me painting in the cube. You can see here, when the status of our search in the app is basically anything in the queue then you can see here which is pending. Okay? That will let me see these. I'm just going to invoke these for 40 names I just clicked it okay. So if you need anything you can see here.

Now if you see my jobs, you will see some that will fill in this now maybe, let me see. I've access all the given to title good, so many minutes. 14 is the income or the income, that's fine. Okay, so this is the implement is enough cable So the other things that we can use to actually listen. So pattern recognition, we use batch effects, similar feature and given up here, so it's best to use q will always close your eyes and global variable. And in future method, we just go class name and method name, but here you have to do system dot integer.

So the system that integer when you do then is going to do job in the queue. Okay. Here, yep. Perfect, but a lot of any confusion, any question from any topic. So I'll start writing the asynchronous jobs, batch and curable em shader as well. Similar you use in the batch reader to do optics and a single batch also like you want to Do some buys after some time that also you can see and use the database or dollars call out to see if you can persist the transaction data to the next level.

Okay. So everything will just try and see, you can see what are the best practices we have in here. So, you I don't ever do admin knowledge. So are you how much exporting admin but like workflow, approval process looks only field that you will appear on the record? Yes. So actually, I have been working on census application for four years now.

Oh, and, but all of my experiences are in admin part. more mobile, mobile as a business. Yeah, yes, kind of. Okay, so now we'll see. And like, what is the order of execution of a trigger? So how many times if I elicit an instance like this, I just go and click contacts a we have a trigger and the contact and how many times?

Or what are the transactions? What are the background process going to happen if I have a trigger? Okay? Is there a trigger going to do once or the there's something else which is going to make us feel good multiple times okay. So, to understand that, we will see the order of addition, which is going to pass off as you could see, I have been a trigger after insert before insert after update, okay, inside the trigger, I may have some other logic I may have seen, I may have some workload pre loaded, if everything works in the system, then participate out of a position who is going to do class, the moment I go click Save, and the record got saved. So till that time, what are things going to happen in my system?

Okay, so to the complete journey of my record, from my user interface, to my database, how it's going to happen is it's manual. form, it's my database. So my record goes from here to here. So now, how it is going, what are the operations are going to integrate, that we'll discuss, it's very important to know it, so that we can write program perfectly. So now, there is two thing. So you are going to initiate the new record, or you're going to update a record.

And I think we're going to go as you open this page. Okay, this form page, nothing. But if I have the data already in my database, which I'm going to modify, I'm going to update so the data will be initialized from my database to here. See, already I have all our data in sync. Or if I want to create a new record, if the empty form will have to enter the data. Okay, let's even enter data and a clap tried to save it is checking some validations my data is there.

And again, Canada isn't content to put somewhere my system reticence and some My custom Bella distance what we have within the giving all these things points how my ignition goes, Okay, past 400 mil is like 1015 steps I'm in the past trying remember always to load my original record if it is existing otherwise if not, then initialize the record the renewal record then it will initialize or the what the spell perhaps on this one to you. Okay, then what will happen, then, if it is my existing record, consider this one if it's my existing record, and I go on it. So I just don't want to use this existing name, I want to change something, I'm avoiding this or I am going to create completely new Anyhow, I have to populate my data on this. But so my second step is coming to always Okay, so we load the new field.

It may be overlaid the data or it may be completely new. Okay, so now on the data what I'm going to insert, I can insert from the page or I can insert from my officialdom maybe point a counter educating, I can go and create a content for example, Okay, number insert of account can fire me a code which is going to create a context in back end. So my, this data may come from the user interface, or may come from my back end, or from episode me, okay, they're going to remember here whenever you are going to modify the data or create a new data from user interface page, okay, if you are new from user interface, then what will happen so in the Page Layout level part of the let's see in the Page Layout, I made title as required field then this will fire only on this page.

If Sam that I will go into insert by periodically Then this page layout attribute body offset it is not going to check okay. So, what happened here? So, always remember, whenever that is the disabused of creating or modifying the record console user interface, we have to check page level by distance okay. And my session will well listen we will show what kind of thing so now, I made it as it let's see in the payload I made my department is record field okay. So, whenever you enter data from the space department is going to be called, but whenever you want to create record from backend, my department is not not required. So, it depends what type of check you need to do.

So if anything you have layouts or speak in the way you can, then layout has pictures, it will happen it may be record fail, it may be anything, okay. that we do. So now. Semi, let's hear in the email field or in the phone field, or the email field. I cannot enter anything else like this, but if I try to enter it Give me field format validations that kind of cycle so we do nothing but I can simply say it will check my field format. It will check my layout suspect check, or maybe my fielding checks.

So he pays for my field of LinkedIn fee for I'm trying to enter up data more than that, they do stop me in the page only. But whenever you want to create the record in backend, maybe by my programming, okay or maybe you using some API calls, okay. Whenever do so, that name also, we check all the CSV karma domain database level, what if I made my title field or the record in my database level, not in a page load, that also going to check. So remember, whenever this data modification or new data created neural activation comes in the system. So we'll check what are the foreign key? Well, let's see in this in this contract, okay, I want to take an account.

Okay? So here anyhow to look complicated, but if I put some wrong account ID in the backend, okay, my account already started user one but I just kept some wrong ID. So that check will taken care when you come from the official roaming. Okay. So, that check, okay, so now what I can say simply, if you come with some API call will check the foreign key references not me nothing but I can say my local machine certain What do you have that is being populated properly or not? proper ID populating there or not.

Okay. So if everything fine, okay, let's see I just kept all the data properly, then I'm going to save it. Okay. The moment I saved my trigger, do some stats. Okay. So what is a three to electrical all before triggers execute all BufferedReader Okay, so now, whenever is a particular use digital complete then I have a 10 minute validation rules.

Okay. So it will run all system medicine rules. Okay. So quite an innovative system built into login. So see, okay anyhow we'll run the medicine rule on the second step only possible. Okay Here we'll run all the version one time.

Okay, so let's see, I wrote one logic in the account. We don't allow anybody or maybe in the contract I don't want anybody can enter body before let me put something before 1900 that badass woman bellowing the system. Okay, we are all 100 assembled there. Okay. So now we have some validation tool, it will allow me to stop here only if I go to customer edition, if about Daisy less than 1900 then stop and so the message but in the trigger, I wrote a logic okay to modify this body to 1900 nothing but if you go to contractors or here I wrote again, con dot, let's see my birthdate okay equal to that dot new instance okay. So I can set again my, some kind of debt, okay, if I do these, okay, then past time when I come from a page in a second second step to it, check all the validations but in the before trigger, I modified that value for that region.

Salesforce will again check if there is anything changes happened in the before trigger, maybe before the uncertainty put up but then again, check all the historical reasons Okay so then what happened we have something really fishy now i was i was getting the contacts I got my duplicate duplicate contacts message I got then I click on the Save ignore same thing so now whenever you think well this one all person past and it will check the duplicate rows if there isn't duplicate duplicate duplicate content it will show though warning messages for medical errors we can catch their messages or we can show the messages on the user interface also how we see it because someday okay then if everything is fine then we'll go on separate according to Dennis, we didn't commit in we just save the recording database but not committed it. Okay, so now once this thing over, then we'll come to the operators.

Now my operation happened so if you need object Okay, then you anyhow lead Okay, so then we'll go to the my assignment. If that assignment rules are available, then it will exist. My all assignment rules. Okay, so same way, the you know, autoresponders will depend. And then you're like, dude, my auto response rules. These are what my objects this week.

So if I have a position custom object, I may not have a assignment rule or responsible. But if it's a lead or maybe case, then we can get my assignment rule out restaurants would then in the object level, we may have some workflow, then it will execute my workflow. Okay. So in the workflow, you may have email alerting, you may have a field update, you may have a heading of task r1 with everything. So easily do workflow rule. After you do some of my after trigger, my record is now ready to save.

Now let's go on and do with my workflow. Okay. But when you do the workflow rule, it will check if there is any field loved it. Okay, everything's fine, but when you come to feel of it, that means I'm updating some field maybe on that account record which I'm going to insert, maybe the same record which in the transition, okay. So, if there is any field update, okay, that means my record is going to be updated again. So I initiate my content audit and my before insert operation over after insert over there my workflow fire, which is going to set my lead so so maybe maybe let me pick some field here which will tell you Okay, maybe I'm just going to set my language as maybe French due to some condition, maybe my depending on some other logic, my languages French, or my level is primary.

I said it in may work level a bit, the moment a certain workload below but what will happen so again, my record is going to update. So now, this record being updated again and as the record being updated again, I don't have any here. Then again, I am going to shoot my before Okay, so it May be prohibited and as of doing so, before auditing then I do it again my after arbitrators any confidential no okay. So we get one more time these things okay. So, when you do this update or listen to this what will happen? What are the standard validations I have okay or validation or what are the validations So, we have written several in the sense let's see, your database required Li required required stuffs like if you want Okay, my contact but this will not be null but it's not allowed.

So that check will do or the steady something is required field which you don't miss everything will go with the standard conditions and the validation rules what we have written that will go under custom medicines. Okay, so it will check one more time. Okay. And also this duplicate rule escalation rule. Everything is going to check Duplicate rule is collision rule everything is going to check. So same way if you have any process builder then we will come to the process process and close.

Okay, did a good that Okay, so then normally if my pillow in order normally I'll go to the skeleton rule if anything they're diligent, okay. And then we come sometimes what happened we may have one rule of somebody in the field, let's see in the contact, I'm going to insert alerts whenever interesting opportunity I may have electronic field to my account, okay. There is a custom object for which I just wanted to work on. So now, if you have any role of summary field, okay, then and if that fields are part of Microsoft formula, in role or somebody believe if you are getting something opportunity, okay, and in the opportunity object 10 some handy one that Phil is being referred in the account rule of my field. If you have any rule of summary field, which is being used in the cross audit workflow, okay, then we'll calculate the value of this value based on this workflow, then this will last on the field.

So what has happened, the value will be evaluated, and we'll get to my role of summary field, okay? And when the solo 20 field happens, nothing but I am going to object my parent record. Hello. So now, let's see, I want to roll up all the opportunity we need to account for example. Now, I modified my account and I modified my opportunity, a new one opportunity, a new vendor, and this is got changed. So basically, in the account level, all the role of value is going to modify and as it's modifying that number, I'm going to save the account once again.

I'm incorrect. So don't think about what is going to happen. So it is going to update Wherever this parent occurs, or maybe parents or instacart, whatever also will never know you have to go and operate everywhere. Okay? Then it will run the sharing rules. If you have any sharing rules defined, then it will discern all the criteria we're setting goals.

Okay? Then we'll go commit till this time we didn't commitment our database, then we'll go to commitment service, okay. After commit, if you have any post commit logic, like sending the email or notifying someone then that was committed logical and this is exactly that trigger flow, trigger ignition flow. Okay. So if you anytime you do something, okay, in this system, it's going to invoke this way to pass laws to record the den, check system validations or payload validation. Then a good might be Patricia then wrong all the medicines okay sister medicines then check the duplicate rule everything fine then save it then interpret trigger then assignment rule or resource rule workflow then even you have what is there in a dude once again this will trigger an appropriate trigger then again check my validation rules then include my process or close then any escalation if you are if your roles only field then again update all the parent records then include sharing rule then commit database and custom but my friend any confusion is not so this this is the sequence which gets towed every time you go here the thickness which include everything So, in essence we may not we may not need everything let's see I don't have to upload then this part will not take dude, let's I don't have a skeleton Oh, I'm just going to do any custom of customization So I may not have a assignment or a response within this particular dude.

Okay, this is what is I will already do this way there is a complete set of steps which going to be good one by one. Okay. Perfect. Okay, so we'll close the session today from this. Okay. In the next lesson we'll discuss the next topic.

So you practice it if anything you have just messaged me, anytime you can just write the asynchronous jobs first and see. Okay, perfect. Okay, thank you. Yeah. Good. Thank you.

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.