Salesforce Apex is programing language for custom development. Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Lightning platform server in conjunction with calls to the Lightning Platform API. Apex code can be initiated by Web service requests and from triggers on objects. Apex basic best practices?… Continue reading Apex Best Practices – Basics (Episode 1)
Tag: Apex
STRING SPLIT WITH MULTIPLE SPECIAL CHARATER IN APEX
Just experienced issue to split the string value, one of API integration where JSON string attribute contains the many special character that I need to split and reorganize the value then store the value in salesforce field. Example: JSON Response { "To": "Test User <test.user@test.com>", "Cc": "Test User1 <test.user1@test.com,Test User2 <test.user2@test.com;Test User3 <test.user3@test.com;Test User4 <test.user4@test.com"… Continue reading STRING SPLIT WITH MULTIPLE SPECIAL CHARATER IN APEX
SPRING 21 – ACCESSING CUSTOM METADATA TYPES RECORDS FROM APEX
In Spring 21 pre release, new methods introduced for Custom Metadata Types as like Custom Settings. Following Methods getAll() - Will return the all records from Custom Metadata Type. Before Spring 21: list<Test_mdt> lstMetaDataRecords = [Select Id, MasterLabel from Test_mdt] In Spring 21: Map<String, Test__mdt> mapMetaDataRecords = Test__mdt.getAll(); list<Test_mdt> lstMetaDataRecords = mapMetaDataRecords.values(); getInstance() - Will… Continue reading SPRING 21 – ACCESSING CUSTOM METADATA TYPES RECORDS FROM APEX
SPRING 21 – PERSON ACCOUNT AND A BUSINESS ACCOUNT AT THE SAME TIME WITH NEW LEAD CONVERT METHODS
For Salesforce orgs that use APEX Lead Convert, Person Accounts, and Contacts to Multiple Accounts, new methods are available on the LeadConvert() class. These methods allow converting leads into a business account and a person account instead of a contact. Note: This change applies to Lightning Experience in Enterprise, Performance, and Unlimited editions. getRelatedPersonAccountId(): Gets… Continue reading SPRING 21 – PERSON ACCOUNT AND A BUSINESS ACCOUNT AT THE SAME TIME WITH NEW LEAD CONVERT METHODS
DIFFERENCE BETWEEN VARIABLE AND CONSTANT IN SALESFORCE APEX
Variable :- Variable value can be change any time. it cant be fix. How to declaring Variables :- You can declare the variables in Apex like String and Integer as follows − String strName = 'My String'; //String variable declaration Integer myInteger = 1; //Integer variable declaration Boolean mtBoolean = true; //Boolean variable declaration Apex… Continue reading DIFFERENCE BETWEEN VARIABLE AND CONSTANT IN SALESFORCE APEX
APEX COLLECTIONS IN SALESFORCE
Simple explanation about collections and its types in Apex: Collections in Apex: A collection is a type of variable that can store multiple number of records or items. Collections are work like arrays and they have more advanced behaviors and easier access methods than arrays. Data collections are groupings of any data types for example… Continue reading APEX COLLECTIONS IN SALESFORCE
APEX DATA TYPES IN SALESFORCE
A data type constrains the values that an expression, such as a variable or a function, might take. This data type defines the operations that can be done on the data, the meaning of the data, and the way values of that type can be stored. Apex supports the following data types Primitive (Integer, Double, Long, Date, Datetime, String, ID, or Boolean)Collections (Lists, Sets and Maps) sObjectEnumsClasses,… Continue reading APEX DATA TYPES IN SALESFORCE
Salesforce SOQL is not SQL
Salesforce SOQL query is not working same way as SQL server Data Base query. why? Salesforce using Multitenant Architecture - Many organization using single instance including data base but each org will have their own virtual hardwares. Salesforce using Force.com platform - It is metadata driven architecture. Query language directly integrated with Apex so no… Continue reading Salesforce SOQL is not SQL
Apex Code – Static Factory for Record Type
Use below apex class to avoid duplicate in your org to pull record type, Profile, User, Environment, Sandbox name, Group Name, Queue Name related information. This is very helpful to me - I was using separate apex class for each area like RecordTypeCommonUtility, ProfileCommonUtility, UserCommonUtility, EnvSandboxCommonUtility not I have combined all together as StaticFactory. public… Continue reading Apex Code – Static Factory for Record Type
How to convert Set Id to Set String in Apex code?
Apex code is not supporting converting set<Id> to set<String> direct way - we have to do workaround - Set<Id> ids = new Set<Id>{'001G0000023lIWq','a61G0000000TOSE'}; Set<String> idStrs = (Set<String>)JSON.deserialize(JSON.serialize(ids), Set<String>.class); System.debug('idStrings=' + idStrs);