Apex Syntax: How to better understand the Apex Syntax and Logic in Salesforce?

Deepika Khanna
A free video tutorial from Deepika Khanna
Software Developer,Blogger,Author
4.4 instructor rating • 31 courses • 90,983 students

Learn more from the full course

Salesforce Development Training for Beginners

Salesforce Development :Learn about Apex programming and Salesforce development. Become a Salesforce Developer.

13:50:14 of on-demand video • Updated September 2019

  • you will have a mastery of programming in Apex no matter what level of experience you are at right now.
  • My goal is not just to show you how to program, but to help you understand what you are doing, and why you are doing it as well!
  • Not only do the videos show you how to become a Apex programmer in great detail, but this course also contains lot of assignments to practice.
  • I'll be constantly adding new material to the course as well as updating it on a regular basis to make sure you access to the best and most update to date and comprehensive Apex training
English [Auto] Hello guys. Welcome back. In this tutorial we're going to take a look at Apex syntax. So what are the different things that are available in Apex program. So Apex program has things like variable declaration you would write a sequel queries loop statements for flow controller statements the email statements and what are each of them. We're going to take a look deep dive into those. But let's see what variable declaration looks like. So you can see here the second line that you see it's a variable declaration on what do you mean by a variable variable is used to store some data. That is what the variable is used for. So here what we are creating is we are creating a variable to store the list of outcomes. If you have more than one account records that you want to store then in order to store that list you're going to need a place holder. So that is what we're done here is we are declaring a variable which will be used to store a bunch of account records. Then the second the next statement looks like select I.D. Call My Name Description from account. So this is called as an essay cool query. Now the Esso will query is used to retrieve data from Salesforce. OK. So if you wanted to pull out information related to an account OK if you're specific if you're interested in a particular account you can use this as so will query in order to retrieve the data. Then the next thing is a loop statement. So let's see there are three records data available or three account records. And in each of those accounts records you wanted to update a particular field of all of those records. So what you will do is you will you will go over these records one by one and update that field of every record. So those things can be done using the loop statement. So here what you're doing is we are using a for loop and we're iterating over. Means we are going over the list account which is nothing but the variable which has the list of account records so we are going over those records one by one. And then what we're doing is we are updating the description field on those records do something like this and then we are adding back to another list. So this is what the loop statements looks like. So if you wanted to iterate over records one by one or if you want to update something in let's say 10 records or 10 account records of what you're going to do you're going to go ahead and update using the for loop you will iterate over those records and update the feed then you have is flow control statements. Now what do you mean by flow control means if there is if you want to achieve something based on a particular condition. So that is call is flow control. So if you're checking if the account update does not equals to null or the size of the list is greater than zero then do this. So this is what if X condition lists flow control means if you want to do something based on a particular condition and if that condition is met do this. If that condition did not meant do something else. So those are called as flow control statements. We'll talk about those in discourse as well. Then we have as DMX statements as I told you those are called data manipulation language which means if you want to manipulate the data if you want to update something if you want to insert the record into Salesforce then you're going to use these statements. So the statement looks like this. So you're making an update to Salesforce this accounts of what you're doing here as you are doing an update to this particular record. So whatever you have whatever whatever the records you have inside of this variable all of those will get updated using this update statement. So this is how the D.M. statement looks like. So these are the different features or these are the different things that you're going to use inside of your apex. And these are the things that makes the Apex program. So we'll have variable declarations you will need some. So quick way to retrieve the data to iterate over the data to use it fails conditions to write these email statements et cetera. So this is what an apex program will look like. Now in the next tutorial you're going to start with a very basic which is called What is a variable and how do we declare a variable in Apex. So I'll see you then. Thank you so much.