Deprecated: Optional parameter $list declared before required parameter $is_script is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 21

Deprecated: Optional parameter $register declared before required parameter $footer_or_media is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 45

Deprecated: Optional parameter $register declared before required parameter $footer_or_media is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 104

Deprecated: Optional parameter $expire declared before required parameter $path is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_functions.php on line 54

Deprecated: Optional parameter $depth declared before required parameter $output is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/themes/entaro/inc/classes/megamenu.php on line 155

Deprecated: Optional parameter $depth declared before required parameter $output is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/themes/entaro/inc/classes/mobilemenu.php on line 147

Deprecated: Optional parameter $args declared before required parameter $wp_customize is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/extensions/customizer/extension_customizer.php on line 583

Deprecated: Optional parameter $args declared before required parameter $wp_customize is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/extensions/customizer/extension_customizer.php on line 606

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":840,"date":"2017-07-27T04:36:47","date_gmt":"2017-07-27T04:36:47","guid":{"rendered":"http:\/\/www.salesforcenextgen.com\/?p=840"},"modified":"2020-12-28T19:45:44","modified_gmt":"2020-12-28T19:45:44","slug":"apex-programming-beginners","status":"publish","type":"post","link":"https:\/\/salesforcenextgen.com\/apex-programming-beginners\/","title":{"rendered":"Apex Programming for Beginners"},"content":{"rendered":"

Apex Programming for Beginners<\/strong><\/p>\n

Introduction to Apex Class and Trigger<\/strong><\/p>\n

What is Apex Programming and why is it required for customizing Salesforce?<\/strong><\/p>\n

Apex is an object oriented Programming language, it is stored, compiled and run on force.com platform and is, therefore, on-demand programming language.<\/p>\n

Apex\u2019s syntax is similar to Java, they behave similar to a stored procedure, and the logic written in Apex can be linked to the record save procedure. Salesforce\u2019s apex provides features for unit test creation and execution.<\/p>\n

What are the capabilities of Apex?<\/strong><\/p>\n

Apex help in programmatic access to the exposed Salesforce.com feature. The list of these features is mentioned below.<\/p>\n

Actions, Approval process, Authentication, chatter, communities, email, metadata, Salesforce knowledge, Salesforce connect, territory management, visual workflow etc.<\/p>\n

What are Apex transactions and Governor limit?<\/strong><\/p>\n

Salesforce has made its foundation based on multi-tenant architecture, to ensure the resources are used efficiently, Salesforce introduced the governor execution limit. Following terms are used together when it comes to talk about Governor limits.<\/p>\n

Mostly Governor limits are applicable per Apex Transactions basis, but some are on rolling 24 hours basis. Apex transaction is the execution of a set of operation as one unit, boundary of the transaction can be a trigger, anonymous code or a web service etc.<\/p>\n

Execution Governors and Limits- since Salesforce is in a multitenant environment,\u00a0 its servers ensures that a single apex code does not monopolize all the resource and keeps a check on all the execution and these checks are known as governor limits.<\/p>\n

Running Apex within Governor Execution Limits- sometimes there arises a need or requirement which wants us to execute code which will breach the governor limit. In those circumstances, to adhere to these limits certain design patterns are used, i.e. bulk calls and relationship queries.<\/p>\n

Getting started with Coding in Apex<\/strong><\/p>\n

Before we proceed to deep dive into the code we need to know certain fundamentals of Apex.<\/p>\n

As we mentioned earlier, the syntax of Apex is similar to java, but there are other fundamentals as well which are quite similar, below are the features similar to Java.<\/p>\n

Data Types and Variables<\/p>\n

Control Flow Statements<\/p>\n

Classes, Objects, and Interfaces<\/p>\n

Working with Data in Apex<\/p>\n

Data Types and variables<\/strong><\/p>\n

All variable in apex have a data type, it is basically an alias for a memory location allocated to hold a value. For eg. sObject, integer, enum etc.<\/p>\n

Then Salesforce has primitive data type, integer string, double etc. It also has collections namely list, set and Map.<\/p>\n

Control Flow Statements<\/strong><\/p>\n

To control the flow of statements, apex provides if-else and loops.<\/p>\n

Conditional (If-Else) Statements<\/p>\n

Loops<\/p>\n

Loops<\/strong><\/p>\n

Apex is presently supporting 5 types of loops, namely: while loop, do while loop, for loop, for-each loop<\/p>\n

For loop with SOQL as an argument.<\/p>\n

Objects interface and classes<\/strong><\/p>\n

Similar to Java, Apex is also based on the concept of Classes, interface, and objects. So what is the difference between a Java class and Apex Class, main differences are mentioned below:<\/p>\n

    \n
  1. Classes and methods are final by default.<\/li>\n
  2. Default access modifier is private, i.e. specifying no access modifier and declaring privately is synonymous in Apex.<\/li>\n
  3. An interface is always global, no other access modifiers are allowed.<\/li>\n
  4. Inner class and interface are allowed only one level deep, inner class behaves like static without specifying it as static.<\/li>\n<\/ol>\n

    How to create a class?<\/strong><\/p>\n

    Salesforce has provided us with the\u00a0 Apex and Visualforce editor in the UI. There are many ways to reach the editor.<\/p>\n

    Kindly note that Apex class and triggers can only be created in either sandbox or developer edition, but Visualforce is allowed to be created at the production environment.<\/p>\n

    Apex Class editor has a help text inbuilt, this helps in auto completion of the syntax, which save a lot of time.<\/p>\n

    Now with all the Bookish knowledge which is available on the internet, we should now proceed to write some code.<\/p>\n

    Next : Working with Data<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

    Apex Programming for Beginners Introduction to Apex Class and Trigger What is Apex Programming and why is it required for customizing Salesforce? Apex is an object oriented Programming language, it is stored, compiled and run on force.com platform and is, therefore, on-demand programming language.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,72],"tags":[40,70,38,48,51,52],"_links":{"self":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/840"}],"collection":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/comments?post=840"}],"version-history":[{"count":4,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/840\/revisions"}],"predecessor-version":[{"id":2218,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/840\/revisions\/2218"}],"wp:attachment":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/media?parent=840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/categories?post=840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/tags?post=840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}