 Hello, everyone. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So as you can see, this is day 43 of Salesforce Learning Bootcamp. And today we are about to complete Apex sessions. So I explained you all the topics related to Apex and today we'll be discussing about some of the scenarios. Those are related to Apex. Okay, so before starting, I just want to show you the exercise sheet. So I just updated it and you can see lots of examples are available. And yesterday also I provided some examples, right? So I hope you have done if you are facing any issue in any of the example, so you can just reach out to me through YouTube comment section or you can just ask for help in the telegram group. Okay, so I hope you all are part of the telegram group. If not, then you can join and telegram group link is also available in the description of the video, right? Now moving forward. So those who just started your development journey and you are following me so you should know with whom you are interacting. So this is about me. And I have a total 16 plus years of experience and helping community so that people can learn Salesforce and they can build their career in Salesforce ecosystem. Okay, so I hope everybody is following all the learning best practices. So I can see people are asking questions in telegram group, but I need more participation so that whatever doubts you are having. So don't hesitate. Just ask questions. Everybody are available. Whoever is online, they will be helping you. So ask more questions, any type of question you can ask and but those will be related to Salesforce. Now, like, since I announced one more bootcamp, so there is one confusion going on like cybersecurity is related to Salesforce or it is different. So for cybersecurity, I will be creating a separate group. So the consultant who will be delivering all the sessions, so he will be answering your questions related to cybersecurity. Okay, so soon I will be sharing that link. So maybe on Monday, that group will be created. So I will be sharing the telegram group link with you. Right. And I hope all of you are doing everything consistently because consistency is the key. I am seeing many folks are asking like we are fresher and we are not getting any jobs. So don't don't worry, do regular practice, have proper skillset, do projects, understand things. If you have some time so do supervisors, those are available on trailhead. So so that you can master your skills, right. And whenever you see any opportunity, so if you do all these things so you won't be presenting yourself as a fresher, you can say like I have six months, this learning knowledge, you can ask like difficult questions. So basis on that you can just try to give interview as an six months experience candidate, right. So just give it a try and do practice consistently so that you can master your Salesforce skill. Because without consistency, you cannot win any battle. Okay, so today's session will be kind of mixed. I will be explaining scenarios one by one. And if you are having any doubt, so we will be discussing them together. And like if you need, I can just copy and paste the code to you. So if you are on laptop, you can practice with me. And you can see how soon we are able to complete week 11. So it's it's almost two months. Like I delivered almost 11 week. And this is session number 43. So next week, we'll be starting new topic that is a big trigger and that is very much important and complex to write. So you you need to understand like how we can write code in a big trigger. So next week will be very much important if you want to become a good developer. Okay, and if you have not followed the platform on different social media, so just follow it and all the important links are available in the video description. So project link, session tracker, day wise exercise link, everything is available in the video description. So just follow that. Okay, so maybe from 17th of April, we'll be starting cybersecurity bootcamp. So I will be sharing all the details about that next week, Monday, so that there will be no confusion. So just to update you now, like from 17th onwards, there will be two separate sessions to two separate timings will be there. One will be for Salesforce that is already going on. And one new bootcamp will be started. Initially, we have planned it for six weeks. And it is named as cybersecurity. And cybersecurity is also available in Salesforce. So cybersecurity is part of Salesforce. And if you know cybersecurity, so you can just go to any other ecosystem as well. Right. And if you are not getting any job, so you can try your luck as a freelancer. So everything will be guiding you. So we'll be having first session on 17th, where we'll discuss everything what are the job roles available under cybersecurity, in which field you can go, what certification you can do, right. So all your doubts will be cleared. And there will be two parallel tracks on two different times and all the sessions will be recorded and will be available free of cost on my YouTube channel. Right. And I will try to create an exercise sheet similar to Salesforce for cybersecurity as well so that you can do regular practice. Okay. So moving forward, we need to discuss some scenarios so that you can better understand Apex programming. So moving forward. So this is the first scenario that we need to discuss. Okay, so just just read this requirement that we need to implement. And I can see some couple of questions are there. So how to navigate from error in logs to class. Okay, so if there are any errors, so those those will be available at the time of implementation. So you can just see from there if if there is any runtime error, so you just need to see the logs. And at the end of that log, you will find that error. Okay, so I will try to show you with this example. So just just understand this requirement. So in today's session, what you will learn, you will learn how we can use SOQL and DML, what we discussed in this week. Okay. So I just have small small scenarios so that you can just start building different methods and you can just utilize SOQL and DML properly. So we need to query account along with related contacts. So whenever you listen account along with related contacts, so it means you need to apply parent to child SOQL, right, that we discussed. Okay, so we discussed that in this week, I think yesterday we discussed parent to child SOQL, and the where clauses where account phone is not equals to null. Okay, so we need to query only those account records where phone is not null. Right, if phone is null, then those account records won't be queried. And whatever account record we will be querying for those all the context like for that particular list of contact with each account, whatever number of contacts are related, they also will be queried. So and we need to display the result in this format. So first we need to show account name, then has then number of contacts. So let's say account name is ACC 101. So we need to write ACC 101 has let's say five contacts related. Right, so this way your results should be displayed. Right, so now jumping to the orb, and here I'm going to create a new class. So naming it as apex scenarios demo. So here I'm going to implement a method. So naming it as public static void scenario one. So a big scenario one. Now here inside this block, I will be writing the code. Okay, so I just need to query account records along with related contacts. So my SOQL will be returning a list of account. So first of all, I'm going to create list of account. And I'm repeating again, if you are on laptop, so you can just implement this with me or maybe before me because you have the requirement. So you can just try to implement it. If not later, you can just practice it by going through the recording. So this way I just created the list. Now I'm just writing ACC list equals to then I need to write select ID name. And then I need to query contacts as well. So select ID from contacts, right? So this I already explained you like this is inner query, which will be querying all the related contacts for particular account. Now here, we need to write from account where phone not equals to null. So this way we can apply parent to child SOQL. So all those account records will be queried where phone is not null. And along with those accounts, related contacts will also be queried. Now after this, what we need to do, we need to apply null check. So I'm writing if not of ACC list dot is empty. Now here null check is applied. So I'm just applying for loop. So account ACC then ACC list. So we are going to iterate on ACC list, which is containing all the data. And one by one records will be available into this ACC. Now what we need to do, we need to apply system dot debug. So the format is first of all, we need to show account name. So account name I can get like this account name, then I need to show the text has. So what I can do plus that inside single quotes I can write has and before and after has I am providing some space then here plus then it is asking number of contacts. So how we can find number of contacts. So you can just write ACC dot contacts dot size. So basically this contacts is also a list. And if you write dot size, so total number of contacts which are related to particular account, those will be counted. And after this, you can write plus and this way you can write. Okay, so context related. So first of all, account name will display then has the number of contacts or digit value and then contacts related. Right. So this way I just implemented this method in front of you. Okay, so this is a solution for our scenario number one. Now I'm going to execute it. So here I'm going to write name of class apex scenarios demo dot apex scenario one. So this I'm going to execute. So locks will be opened. And here I'm just clicking on debug only. So you can see the result. So ACC 140232. This is account name has zero contacts related. Genpoint has one contact. Then this next one, United Island gas has one. Then this United Island gas Singapore has two as communication has three. So all those account records are queried where phone is not null. And whatever number of records they have that is populated here. Okay, so this way I hope you are able to understand this requirement. So such an is asking we did not defined ACC in ACC dot so such in here is the ACC. So this is the variable which is receiving each account record and through that account record, we are just fetching contact and this size is the method. Right. So this way I hope you understood how I implemented the solution for scenario number one. Right. So if you have any question you can ask. So today I will be answering all the questions just after the scenario. Let me open the chat as well. So Raghav is asking about absurd DML so Raghav absurd DML I already explained. So I think you can just watch the recording again. And there are some questions. If you if you try those, I think you will be able to solve them. So here absurd related scenarios you will find. Yeah, here it is. Number nine. So just try it out. If you if you face any difficulty, so you can reach out to me through telegram. So I will help you out. Okay, so okay, there is one question. Why not write phone field in SOQL. So I am just moving here. So you are saying why we didn't write phone here because in this logic, we are not using phone field. We are just using it for a wear clause. So we are writing it after wear. So if if you don't need particular field in your logic, so you don't need to query that. Okay, so I'm just repeating this ACC dot context dot size. There is one more question related to this. So what is happening ACC is giving one account dot context means the context which are related to that particular account, because here we applied parent to child SOQL and size means like those related contexts are how many in number. So size will be calculated calculating that size. So this context is basically a list. Yes, you can you can do SOQL through Salesforce inspector as well. So if you go here, so here Salesforce inspector is available. So here data export import options are available. So you can utilize. And if you want to see all data, so everything is available, you can utilize that feature as well. And you can just use this query editor as well if you want to check your queries. So upper nice asking no need to create contact list. No, because account is querying data through parent to child. So account list is capable enough to store all the data account as well as contact. Okay, so someone is asking why we use a picks when we have flows. So for complex implementation for heavy objects where lots of code is implemented. So in that case, you should prefer trigger and a picks, right? For simple implementation, you can go with flow because in complex implementation, it is very difficult to manage the flows because in flows you have limit for elements as well. Yes, Raghav, you can use acclist.size for null check. Okay, so I think with this scenario, there is no question related. I answered all the question. Now let's jump to next scenario and please ask questions related to the scenarios because it distract the sequence of the session. If you want to discuss questions other than sessions, so you can ask at the end. Okay, so please ask questions related to this particular scenario only so that I can cover all the answers when I see different questions. So it seems like I need to go ahead and explain another scenario. Okay, so scenario two says query account along with the related opportunities where account phone is not null and you need to display the resultants in this way. Account name has then total amount on related opportunity. So if one account is having five opportunities, so all those five opportunities amount should be summed up. Okay, so let me take you here. So on account, let's say we have this opportunity. If I open the opportunity, so on opportunity, we have this amount field. So what we need to do we need to calculate some of this amount field, right? And all the sum we need to display. So if one account is having more than one opportunity, so all those amount will be summed up. Okay, so I'm going to implement this scenario in the same class. So public static void, it picks scenario two. And now here, so I'm just copying this. And here instead of context, we need to write opportunities, right? So if we go to opportunity object, so I'm going to show you how we can decide like from where we can pick the child relationship name. So under object manager, I will be searching for opportunity. So here you can see this lookup is available if I open it. So here you can see we are having child relationship name, it is opportunities. So the same name I'm using in the code here, right? So this way you can find child relationship name in the lookup or master detail field, right? So here what will happen? Account along with related opportunities will be queried and here we need to query amount as well because we will be calculating some basis on this. Then I'm just copying this piece as well. So here null check is applied. Okay, so after null check, I'm just reiterating on the account list. Now here for each account, we need to calculate some. So here I'm creating a decimal variable total, which is initialized as zero. Now I'm implementing one more loop which will iterate all opportunities. And from where we can find opportunities this way. So this I already demoed you yesterday while explaining parent to child. So this account list is having all the accounts as well as related opportunities. So one by one, all account will go to this ACC. Through this ACC, we can have the opportunities like this. So one by one, opportunity will go to this OPP. Now here what we can do, we can write total equals to total plus amount. So one by one through this loop, all the opportunities amount will be added into this total. And after this, what we can do. Okay, there is some error. Okay, it is saying variable does not exist amount. So I just need to write it like this OPP dot amount. So I just need to reference it through this OPP OPP dot amount will be added into total. Now if I show you the format, so we need to write account name then has then total amount worth opportunities. Okay, so I'm just copying this and I'm pasting it here. So account name has now here I need to write total worth opportunities. Right. So this way, we did some calculation here and the result will be displayed here. So this will happen for one account. Then again, loop will iterate and total will be initialized with zero. Then for next account, this loop will this loop will be iterating again. Okay, so now I'm going to execute it. So this is apex scenario two. Okay, so you can see so someone was asking like how we will be removing the errors. So here null pointer exception is available argument cannot be null. So basically what is happening for few opportunities for few opportunities. This amount is null. And if amount is null and if you are using it to like to add the value into total, so it is not allowed. If it is null, so what you can do you can apply if OPP dot amount is not equals to null, then only this total will be calculated. Right. So this way you can just identify the errors. So again, I am repeating the process. This account list is having all the account records along with opportunities. So one account first account will go to this ACC total will be starting from zero, then that account is having for example two opportunities. So this inner loop will be repeating two times. Okay, so one by one each opportunities amount will be checked. If it is not null, then that amount will be added into total. So this will happen twice. Then once this loop is completed, so the result will be displayed through this system dot debug. Then again, we will go for next account record total will restart from zero. And then whatever opportunities are related, those will be iterated. Okay, so I'm going to execute it again. The locks are opening. So here you can see the result where there is no opportunity. So zero or maybe amount is zero, but opportunity is available. So wherever opportunity is available, amount is populated. So that value is available. Otherwise it is showing zero also. So this way you can see account name has done this worth opportunity. So this way we are able to calculate. So we we took it decimal because amount is of type currency, I guess. If I check here, so amount is of type currency, which is having decimal values. So that's why we took decimal instead of integer. Okay, so let me see the questions now. So asset I already explained whatever is required. So if you follow all the sessions, so I am just explaining the topics which are mostly required, like whatever topics I'm covering in this bootcamp, those topics anyhow you need to know, if you want to become a good developer. And other than this, there is lot of things are available. So if you complete this beginner path, then you can yourself explore the things and you will be able to understand those those things. Yes, first I will be explaining test class implementation. So I think you have gone through with this session tracker. So here we have apex test classes. So at this point of time, I will be explaining. So Raghava, I already told you or explained everybody like from where you can pick that child relationship name. So Anujai already explained the iteration one more time. Yes, Nusrat, we can use aggregate result to calculate some. But here we have parent to child SOQL. So that will be difficult to manage. Right. It is parent to child, so it will be difficult to manage. So this is the easiest way. So for parent to child, the number for parent to child, like anyhow, you need to use nested loops. So it is it is good practice, but try to restrict nesting level for two or three levels only. If you go beyond that, then it will be a problem. So Fez and we cannot save opportunity without selecting stage stage is required field. So Nikhil, basically we checked this null condition so that it is not added. But here you can see it is zero. So that zero is displayed here. So due to this if condition amount is not added, but this total is zero, that's why that total is displayed here. Okay, and Kumar is asking, please include integration. So integration and visual force, I already told you will be added soon. So I will be updating. So right now we are focusing on apex part. So don't worry about that. I will be delivering everything for you. No need to worry. But it will take time because on daily basis, we are learning something new and Salesforce is very vast. So I can cover one topic in one day. So you just need to have patience. Okay, moving forward. Yes, so we can use this scenario for required fields as well. And one more thing I want to show you, like instead of writing this null check here, we can write this SOQL directly here. This is also correct. Okay, so you can just use for loop like this. So in the first line of for loop, I'm writing this SOQL so null check is not required. And this is also correct. So this is as per best practice. So try to write your SOQL in the first line of the for loop. Okay, so jumping to the next scenario. So next scenario will be using both SOQL and DML. So we need to query opportunities created this year. In this year, whatever opportunities we created, we need to query. If the opportunity stage is closed one, then we need to update description as opportunity is closed one. If closed lost, then description should have opportunities closed lost. Otherwise, opportunity is open. This is the requirement. So first we need to query the data. And then we need to update those records. Okay, so I'm going to implement this. And the scenario implementation is very much important for the beginner. And Pheasant is asking, how can we remove required from opportunity? No, so on opportunity, three fields are required name, close date and stage. So those are by default required, you cannot remove that required for those fields. Okay, so here what we need to do, we need to query opportunities. So I need to create list of opportunity, right, then I'm writing OPP list equals to then select ID stage, because we need stage. So I think API name is stage name, let me just confirm. So whenever you have any doubt in API name, just search it under search it under object manager. Yeah, it is stage name. So I'm going to use it from opportunity where created date equals to this year. So this is basically a date literal. So let me just go here and search for date literals on Google so that I can show you. So these are date literals that you can use. I think I already showed you in one of the session. So this year, so here it is this week last week next week last month this month next month. If you go down so we have this quarter last quarter next quarter this year last year next year and other examples also. So this is a very helpful document which is provided by Salesforce and it is freely available. So you can just go through with this date literal. So from here, I just used this one this year. So all the opportunities which are created this year, they will be queried. Okay. So Sam is asking if we write a SQL in the first line of loop. So it will be returning list of record automatically. Okay, so now what I'm doing, I'm just applying. Okay, let me just write it. No, let me just implement null check. Okay, so I just apply null check if OPP list is not empty, then we need to implement a loop. So opportunity OPP, then OPP list. Now here I need to apply if condition. So how to apply conditional statement loop. These all these all things we already discussed. So now I'm going to implement it. Right. So if OPP dot stays name, double equals to closed one. So here we have the stays pick list field, you can go here and you can see like it is closed one and closed lost. Right. So here I'm using this closed one. And if it is true, then what I need to write OPP dot description equals to opportunity is closed one. Then else if OPP dot stays name equals to closed lost, then you need to write OPP dot description equals to opportunity is closed lost. And then else OPP dot description equals to opportunity is open. So this way you can just write the code, right? So we implemented a loop and inside this loop we are performing these operations. Once everything is done and loop is completed, so we can write update OPP list. So this way here I'm using DML statement. So if we write SOQL in the first line of the loop, then we don't need to use null check. So if you see here, so here I wrote this here and we don't need to write null check because it is controlled automatically. If there is no record, this loop will not iterate automatically. I hope this answers your question. Now I'm going to run this and before that, let me go to opportunity record. And here you can see stages prospecting. It is not closed one or not closed lost. And here we can see description is blank. So like we'll be updating few of the opportunities. Now how to verify. So what I'm going to do, I'm going to copy this and going to run it under query editor so that I can have some data. So total 266 opportunities I created this year and they have different stages mostly are having prospecting and but mixed are also available. Now I am just squaring description field as well. So you can see description is blank for most of the opportunities. Okay. So this way we just queried the existing data. Now what we need to do, we need to run this code. We need to run this code what I implemented here in front of you. So I'm going to run it apex scenario three. So I'm just saving this code running apex scenario three clicking on execute. It is executed. Nothing will be available in the logs because we don't have any system dot debug. Now what I need to do just go to query editor and run this query again and just click on this refresh grid. So here you can see the data for prospecting and need analysis qualification. It is opportunities open if I scroll down. So here you can see for closed one it is opportunities closed one for closed lost it will be opportunities closed lost. So this way data is populated. So there is no opportunity with which is closed lost but closed one and other we are having so basis on our condition description field is updated. Okay. So this way I hope you understood how we can have the combination of SOQL and DML. So here I just queried the data first and then I applied DML. So this is the complete method that I implemented. So first you need to query the data then apply null check then iterate and then apply condition and after completion of loop you can just apply update DML. Okay. So this was our apex scenario three. Now let me go to the chat. So yes, Sachin this scenario will help shortly while we'll be discussing about trigger. So Sam you're asking but you wrote like checking with account data type. I didn't get your question. Can you just retype your question? Rave the I think your question I already answered. Yeah. So Sachin is asking here we did not add it opportunity to list. So if you see opportunities are already there in this list. So they are already part of this list and we are updating that that list. So we don't need to add those opportunities into any other list. Yes. We can create opportunities says custom but why to create because it is already available and probability and forecast these are calculated automatically. So there is some standard automation available. So if you want you need to create it as custom but you can do yes when I we can do same scenarios using flow as well. Thank you Vishal. So those who are learning and feeling happy like they are learning apex easily and trust me it is very easy the coding learning coding is very easy. What you need to do you just need to do regular practice. Right. So as an arts graduate I learned programming through practice and from last 15 16 years like I'm playing with programming and I learned a lot of programming languages. So I just learned those skills through practice only. Right. If you do regular practice you can just learn anything. Okay. So let's jump to scenario number four. So scenario number four says query accounts created this year and we need to populate total context field on account by counting number of contacts associated with account. So if you recall scenario number one so in scenario number one we already counted total number of contact but in that scenario what we did we just showed the counted value in the logs. We didn't update that on any record but right now we will be updating account. So what is the requirement if any account is having some set of related contacts. So those related contacts count will be available on account record under this total context field. Right. So first of all we need to create this field total contacts on account. So I am just going to name it. So first of all I am selecting data type as number. Okay. So I will be naming it as total contact count. So the one which we created while we discussed flow so that field is total contact but right now I am creating total contact count. So you should also create the field in the same way if you are following all the sessions. If in your case total contact field is not available then you can use that name also. Then I am just clicking on next visible to all the profiles clicking on next and save. So this way I just created the field. Okay. One more thing what I can do I can just set that field default value as zero. So I am going to add it and here I am going to set the default value as zero saving it. Okay. So let's jump to the developer console and I am going to implement one more method for you. So public static void apex scenario four. Okay. And we need to create list of account ACC list new list of account. So it is initialized then I am just going to query the data. So select ID name and this time we need to apply parent to child SOQL because we need to count total number of context as well and while querying accounts we need to apply where close as this year. Okay. So name is not required. I am not going to query that then select ID from contacts then from account where created date equals to this underscore year. Right. So this way I implemented this SOQL then I can apply null check ACC list dot is empty. Right now inside this condition I can apply the loop. So for account ACC ACC list and inside this loop I need to write the logic. Okay. So in this logic we need to count and that counted value we need to store in ACC dot total contact count. Okay. What I need to do I just need to refresh because after field creation I didn't refresh this developer console. So I'm just saving this code and refreshing. Okay. So I just need to close all these tabs and I'm going to open our apex and I use demo. Now here ACC dot total contact count field is available. So what you need to write ACC dot contacts dot size. So here in this situation we just need to count the number of records. So you don't need to write one more loop one more inner loop is not required. You can just calculate size directly through this size method and that calculated size will go to this field automatically and after completion of this loop you can just write update ACC list. So account list will be updated and all account will be having total number of contacts available in this field. Okay. So I'm just saving this code. Now what I'm going to do I'm just querying. Okay. One more thing we are using this field. So this field we need to provide here if you are using particular field in the logic so that you need to query. Now I'm just copying it and going to run it through query editor. Okay. There are lots of errors. Okay. I need to put a comma here. Now errors will be gone. So you can see how problematic a comma is through that comma we got eight errors. So comma is very important. Okay. Now in query editor here also I need to put a comma then I'm clicking on execute. So you can see this total count is blank and for few records we have contacts for few we don't have any contact. So here I'm keeping it as is now after executing this code I will be running this query again so that we can check the result and you can check the result on the UI as well but in that case you need to create a new list view so that you can filter the records which are created this year. So for testing purpose you can just use this query editor which is the appropriate way. Now I'm going to run it. So here I need to write name of the class dot name of the method. So I'm just executing it. So it is showing errors so required field missing. So some of the account field sorry some of the account records which are created prior to making this field required they are not getting updated. So what I need to do here I need to apply a condition if acc.active is null then acc.active equals to yes. And here I just need to use this field. So I'm just saving this code so this way like if active field is already populated so that will be skipped if it is null then only that will be having yes. Okay yeah so Vishal your your joke is making me smile like comma make our code in comma stays yeah. So I appreciate your sense of humor it is required because sometimes coding is very boring so we need humours a lot so those who will be watching the recording so if you're watching the recording so Vishal cracked a joke so this is good he's able to relate the problem so I'm just saving this code executing it again so it is executed nothing will be available in the logs as debug other things are available but no debug value because we didn't use system dot debug now I'm going to run it again and refreshing the grid you can see the data wherever contact records are available we have that particular value basis on number of context related if no contact it is zero because we already set default value as zero for that particular field which we created so this way you can verify the result okay so I think this is very much easy and clear now so we used SOQL DML loop if list so everything whatever we discussed in last three weeks these apex scenarios are like collecting all those things together right so this session is very much important I can see today less candidates joined but those who have not joined so I hope they will be watching the recording and I know IPL is going on in India so that is clashing with this time but I can't do anything because IPL is having huge fan following us and no one wants to learn coding like right so if if you're watching the matches so I would request don't break the consistency that we are maintaining from last two months right so if you're missing the session so just watch the recording and do practice through practice only you can become perfect okay and I'm also missing IPL along with you because I'm doing this these sessions live so sometimes we need to miss something to achieve some things right so after this session like after 930 or 945 I think lots of match will be remaining so you can just enjoy that and you can do multitask as well I sometimes too okay so I hope you understood this example very well let me see the chat now so someone is asking about best practices for apex class SOQL DML so I think people are not going through this session tracker I need to open it again and again so here you can see I will be having one session on day number 51 where I will be explaining apex SOQL DML and trigger best practices all together right and if you if you don't have link of that session tracker so that link is available in the description of each and every video and someone is appreciating my effort so this motivates me your appreciation is a fuel for me and I'm doing it free of cost so I need more fuel so just keep motivating me so that I don't break momentum so Sanjit is asking why we need to query those fields that we want absurd yeah so we need to query the fields because we are using them in the logic if you don't query you will get an error right Sachin I already explained this so ACC dot context dot size means this ACC is one account record that one account record is having maybe more than one context so those contexts will be available in this context list which is created through that parent to child SOQL and this size is basically calculating the size like how many number of records are available under under that context list so this way it is working okay created date variable does not exist but for me it is working so I think you missed comma here so you are in comma mode Vishal we have one guy who missed comma so you can smile your joke is working so Jenna just just put a comma after contact underscore count underscore underscore C maybe because of this it is breaking okay Anuradha you are asking I just used ACC list in capital so apex is case insensitive right so if you write uppercase lower case if you like by mistake write something in uppercase so that will be ignored and it will be running properly but we need to follow case sensitivity so what you can do you can just write it in small but if you write it in capital then also it will work Arjuna I just can't share the slides other than that everything is shared yes if you have a job then you can buy tickets for sure otherwise struggles are there so Vinayak is asking about formula so what formula you want to use yes we can use formula if you want to yes Praveen we can apply a check like filter by user but like created by so that for that you need to do some research so I think instead of created by you can have owner owner is a field so you can use that so you need to do some research and then you will be able to thank you across and deep Kumar for appreciating my time and effort so shaker for how to query second highest salary so we have max and min we don't have second max second min so you need to query the data and then you need to apply some logic so here your data structure knowledge will be useful okay Janna I think your query is now working your query is in live mode from the comma mode yeah Vishal is enjoying today's session a lot so saaji we can have one level of parent to child thank you umka yeah these these claps thumbs up motivates me so keep on motivating me because it is number 43 we need to complete almost 100 sessions so I need your motivation yeah so like in session for the first time someone cracked a joke so I I didn't control my smile so that's why thank you Anuradha for appreciating so if if there is no relationship then we cannot query we cannot apply inner query inner query you can have if you have master detail or look up sonu is saying some folks are in sleep mode so they are not in sleep mode they are they are like maybe smiling or they are just stalking so that is also okay thank you Raghav thank you so so let me see whether we have one more okay so we have one more scenario hold on don't go anywhere we have one more scenario still you need to wait so we need to query so this is for child to parent so one scenario we need to understand for child to parent as well so we need to query contacts created last week and if mobile phone is not populated on contact then we need to copy phone of related account that this scenario we need to implement with the help of child to parent as a cure so this time as a cure I will be applying on contact and along with that I will be querying the related account phone field right okay so moving further let's create one more method so here I am going to create list of contact so it is con list new list of contact so here I am going to apply sql so what we need to do we need to query id then mobile phone so we need to see mobile phone field api so never be overconfident in api names just search so that you can have exit so from here you can copy mobile phone and you can paste it and along with that we need to query account phone so this way you can write child to parent and then from contact now what is where clause where clause is last week so I don't know where whether we are having any contact created last week so where created date equals to last week okay so first of all let's copy it and check whether we have some data or not so you can copy and paste it here and run it we don't have any data no problem so let's make it this year so this year will give you the data so here you can see for some of the accounts we don't have any phone so if phone is null we won't be copying if there is phone then we'll be copying so let's say this this example here for mobile phone is blank so we'll be copying this account phone if mobile phone is available then we won't be modifying so we need to apply these logics okay so here I'm writing null check first okay so if sorry for so we need to iterate on contact list first so one by one context will be available into this con variable so what I need to check if con dot mobile phone is null and con dot account dot phone is not equals to null then con dot mobile phone equals to con dot account dot phone this way we need to apply the logic so what I'm checking if on contact if mobile phone is blank and through contact we are getting account dot phone if it is not null if both are true then only account phone will be copied into mobile phone field okay so here what we can do we can just write update con list so now if I run this code so changes will be done okay so I'm just reading three values comment so it is quite motivating so so I think everybody can read so she is learning easily so she's saying she's already having 70 percent knowledge and now that went up to 90 percent 10 percent is remaining and that if you do more and more practice so you will be having great and I I don't know what about others so I think others also getting more than 90 percent I'm trying my best so this way it is implemented now I can just execute it done execute it so I'm just closing it here I'm just executing the SOQL refreshing the grid and checking the results so here you can see it is updated and now you won't find any contact where mobile phone is blank and account is not blank if account phone is populated so mobile phone will be there okay so you can experience it while implementing in your org so this code is available and I also showed you like how through code through query editor how you can test as well so you don't need to go to UI opening each and every record and it will waste your lots of time so you can just test your code through query editor itself okay so this is it for today and this is the end of epics sessions so it took 12 sessions 12 long hours we did we we both did lots of efforts you are investing your time I'm sharing my knowledge so we both are like exchanging information together and I hope by time you will become pro in Salesforce development okay so practice questions are there so you can see here some questions are available which are related to custom custom objects so always remember when you will be creating custom relationship field mark my word if you are creating custom relationship field so for both parent to child and child to parent you need to use underscore underscore r and again if you see any error any problem in these use cases for today's session day 42 41 so just use the telegram group and ask questions the person who who have already solved they will be helping you with the solutions right and lots of scenarios are available under my website steadysalesforce.com so if you go to scenarios epics so here you will find lots of examples so under scenarios here lots of examples are available you can go through with them as well okay so this is it for today thank you so much for joining today's session we'll see each other next week Monday okay I think there was some internet issue so yep so LWC sessions will be soon so Janna just just implement and if still you will be having doubts so you can reach out to telegram okay okay guys see you on Monday thank you for joining today's session take care bye everybody