 In this lesson, I'm going to implement cueable Apex. So first of all, I'm going to create a Apex class. So this Apex class name will be update parent account. And in this Apex class, I am going to implement cueable interface. So before implementation of code, let's jump into account records. So if I open any account record, so on that account record, you will see, we have a field called parent account. So for certain records, I will be populating this parent account with the help of cueable Apex. So in my previous lesson, I already told you the difference between future method and cueable Apex. So in cueable Apex, we can process beyond primitive as well, like as objects we can process. So that you will see in this demonstration. So here I'm creating private list of account, ACC list, and one more variable I created known as parent account ID. So this ACC list will be the list where all the accounts will be available on which I need to populate parent account ID. And the parent account ID will be available in this variable. These are private to this class only. Now I'm going to create a constructor. So in this constructor, two arguments will be available. First parameter will be receiving list of account records. And second parameter will be receiving particular ID. Now I'm using this dot, this dot ACC list equals to ACC records. And this dot parent account ID equals to ID. So whatever value will be available in this ID that will go to parent account ID. And ACC records list will be copied into this ACC list. And for class variables, we generally use this keyword known as this. Now after defining this constructor, I'm going to define execute method. So as we are implementing cueable Apex, so we need to define this execute method only. If we implement batch, so in that case we need to define start and finish as well. But here in cueable Apex, you just need to define only one execute method. Then this parameter cueable context, variable name is context. Now I'm iterating a for loop. So inside this loop, I'm writing account ACC, ACC list. So this loop will be iterating on ACC list. Now ACC dot parent ID equals to parent account ID. So the records will be available in this ACC list. They are iterating with the help of this for each loop. Each record will be available in this ACC variable. And with this ACC dot parent ID, the ID which is stored in this parent account ID variable will be copied. So it means each account record will be having a parent ID. Now after completion of this loop, what I can do, I can write update ACC list. So this way this cueable Apex is implemented. Now I just need to execute this cueable Apex. So for that purpose, I am opening anonymous window. And in this anonymous window, I will be first querying some records and then we'll be calling this cueable Apex. So I'm creating list of account ACC list. Then I am selecting ID, comma count where billing state equals to NY. So these will be the records where we need to populate parent ID. Now I'm going to fetch one account record so that that account records ID, I can populate as parent ID on the records which are available in this ACC list. So here I am writing select ID, comma count where, so I am moving here and I'm copying this name, account 025. So I will be using this here, where name equals to this dot, sorry, zero dot ID. So this way you can see like one record will be queried as you know, SOQL always returns a list. So that's why I used zero, zero th index and dot ID. So the account record which is available on the zero th index, it's ID will be returned into this parent ID. So we have both the data. We have account list where we need to populate parent ID and this parent ID variable is having particular account ID. Now what I need to do, I need to create instance of update parent account class. So creating instance as update job, then new update parent account, then passing first parameter as ACC list and second parameter as parent ID. Now after this, I just need to write ID, job ID equals to system dot NQ job. And here I need to pass this update job. So when this NQ job method will be executed with the help of this update job instance, so one job ID will be returned and with the help of this job ID, you can track the process status of the job that is created. So now I need to execute this. So I'm just copying this and just moving here so that I can have the list of account records. So I'm selecting all accounts and here you can see we have billing status NY, right? And we don't have parent account. So I'm just going and dragging that field as well. So this is parent account and shifting it to above. Same. So here you can see this parent account is available and it is blank for all. Now after execution, you will see like wherever billing status NY, so parent ID will be populated and parent ID will be of the record which is varied as account 025, right? So now I'm going to execute this code. So I'm clicking on execute, it is executed. So here if you refresh this, you will see your EPICS job base. So you will see one entry. So here you can see job type is cueable and status is completed, total batches 0, batches persist 0, failure 0, and this is the job ID. So let's see what happens when I refresh this. So I need to select all accounts again and here you can see where billing status NY. So here you can see parent account is populated as account 025, right? So this way, with the help of this code, like we are able to perform cueable EPICS operation and this is the way like how you can query the data and you can pass it. Now after understanding this, we need to implement its test class as well so that we can cover the code which is implemented in this cueable EPICS. So I'm going to create new class and naming it as update parent account test. So as you know, whenever we create any test class we need to use this at the rate is test annotation. Then I'm using at the rate test setup. So in the setup method, I will be creating the data. So static void setup. And in this setup method, I'm going to create the data. So list of account, acclist equals to new list of account. Then acclist.add your account name equals to parent. So this is the account record which will be the parent account for several accounts, right? Now I'm iterating one loop and in this loop I'm going to create 100 account records. So this way with this loop, 100 account records will be created and they will be added into this acclist. Now after completion of this loop, I can write insert acclist. So all the account records will be inserted. So this way through this setup method, I created the data. So I created both parent account and as well as the accounts where I need to populate this parent ID. Now creating one more method and defining it as address test. So private static void test queueable. And inside this method, I'm going to query parent record that I created about in the setup method. So I queried the account record where name is parent and it will be available on the zero index because whenever we apply SOQL, so list will be returned. So zero th index and then ID. Now after that, I am writing one more statement, list of account, acclist equals two, then select ID name from account where name like test account. So all those records will be queried where name is like this. So now we have both the things. I have the list account list where I need to populate the parent account and the parent account will be this record. It's ID is available in this parent ID. Now I can create instance of this update parent account queueable, it takes class passing these two list, these two parameters. So first parameter is acclist and second parameter is parent ID. And these two parameters will be passed into this constructor into these two parameters, right? Now after creation of this instance, I need to call the NQJob method. So for that, I'm just writing test.starttest and here system.NQJob and I'm passing update job. Then test.stoptest. So this way NQJob method will be calling the queueable Apex and which queueable Apex whose instance we created and we passed here, right? So this way a queueable Apex method will be executed. This is the method which will be executed. And now we need to apply a system.assert so that we can check whether proper execution happened or not. So I'm checking it like this, 100 comma. And here I'm directly writing, select from where parent ID equals to parent ID. So here we have a parent ID and I'm wearing that parent ID variable with this field that will be available on the account records. So after execution of this NQJob, these 100 account records should be updated with the parent account. Like parent account field will be updated and with this SOQL if like 100 count is returned so this 100 will be equals. So this way I implemented the test class for queueable Apex. Now it's time to execute this test class. So I'm just clicking on this run test. Okay, it is failing. So let's see what is the mistake. Okay, there is some mistake in the assert statement. So actually I did a mistake. I just forward to put percent sign here because I was querying the accounts where name is like test account but actually we created test account with this I variable. So they will be having one, two, three, four, five. So beginning will be test account and then they will be having the digits. So when I put this percent sign, so in that case it will execute properly. So now again I'm clicking on run test. So you can see it is executing successfully. All tests are passed. And if I go here and check the code coverage so it is 100%. So this way with the help of this test class like we can validate our code is correctly implemented and 100% code coverage is there. Now briefly I'm going to demo like how you can chain more than one processes with the help of QABLE-Epics. So for example, let's implement one Epics class named as first job. And here you need to implement one interface QABLE. Now inside this you will be implementing execute method. So here you can write some code that you want to execute. And inside this with the help of system.nqjobs you can initiate next call for another QABLE job. So let's say we have one more class named as second job. So if you are implementing this first job as a QABLE class and this is already implemented. So with this first job you can initiate second job. So when this execute method is executing so it can initiate the execute method of this second job class. So this way you can create a chain of QABLE-Epics classes. So this is a simple demonstration that is like showing how you can create chain of QABLE-Epics jobs. So this is all about QABLE-Epics demonstration.