Saturday, 2 February 2019

Why to use Database.Stateful()?

Database Stateful is interface. It is used in batch classes to maintain the state of the class across transactions i.e. if you want to use modified class variable in execute or finish method across multiple transactions, you have to use Database.Stateful. Only instance variable can retrieve the values between transactions. Static variables resets on each transaction.

Database.Stateful affects batch performance and therefore you should use it only if it is absolutely necessary because the class will be serialized at the end of each execute method to update its internal state. This extra serialization results in longer execution time. If possible you can use alternative method to maintain state of the variable and i.e. storing value in the object and retrieving it on each transaction. 

Friday, 1 February 2019

Salesforce Org-Wide Defaults and Object security and Ownership

** Below matrix is built considering there is no custom sharing rules or Role Hierarchy.

Object access @Profile Org-Wide Default Setting
Private Read Read/Write
Owner Other users Owner Other users Owner Other users
No Access  No Access No Access No Access No Access No Access No Access
Read Read No Access Read Read Read Read
Read/Write Read/Write No Access Read/Write Read Read/Write Read/Write

How to find field access in Permission Sets and Profile?

FieldPermission is the Salesforce internal standard object. It is used to store field permissions given through Permission set and profiles. 
For example if you want to find access of custom fields like Rate__c and Compititor__c from Account object. You can use below query to find the field usage:
SELECT SobjectType,Field, PermissionsRead,PermissionsEdit, Parent.Name, ParentId FROM FieldPermissions WHERE PermissionsRead = True and Field in ('Account.Rate__c','Account.From1__c','Account.Compititor__c') AND SobjectType = 'Account'
For Read access you can use 'PermissionsRead' and for Edit access, you can use PermissionsEdit field of FieldPermissions object. 

ParentId contains either permission set id. If you looking for field access in permission set then you can use Parent Id as it is But if you are looking for profile id then please follow:

  • When you assign FLS through profile, Salesforce stores ParentId in the form of Permission set. 
  • So to get actual profile ids, you have to add Parent.Name field in the query. 
  • That will give you 'X00e600...' id. Remove X00 from the id and rest of it is profile id. 

Path to Platform Dev II

For almost last three years I was scheduling and canceling this certification exam. There was no major reason behind it. It was just my fear to fail. In this due course of time, the exam pattern got changed (I will come to it later). Finally, in 2018, I made mind and I did not only schedule it but cleared the certification
In all these years, one thing I did not give up and that was reading salesforce related material. Be it articles, books, blogs, I read whatever came in front of me. I did not stop there. I used to take notes and paste a copy of that article beside that notes for future reference. For better understanding, I tried to implement that knowledge in real world. It really helped me not only to understand what I was reading but cleared most of my doubts that I was facing in my work. So, do not forget to read in spare time.
Now, let’s talk about the exam pattern. It contains two major sections as follows:
  • Proctored multiple-choice exam (60 multiple choice question with 120 minutes.)
  • 4 Trailhead superbadges.
You can go for either one first. I first cleared multiple choice exam and then I completed all my superbadges.

Multiple Choice Exam

For multiple choice exam, I went through each and every topic mentioned in the Salesforce exam guide. I also referred the articles from Salesforce training material. When you read these articles, Salesforce gives you more suggestions related to that topic. So, I would recommend you follow those suggestions. It worked for me and I am sure it would do for you too.
Some of the key points I would like to mention while preparing for the exam:
  • Apex Performance
  • Continuations
  • SOSL query
  • Future methods use cases
  • Callouts and limitations
  • Batch Job
  • Programmatic Sharing
  • Webservice
  • Heroku Connect
  • ActionFunction
  • Actionpollar
  • Transactions
  • External Objects
  • QueryMore
You must know Apex, Visualforce functionality thoroughly. For that, you need to have few years of hands on experience in Salesforce. REMEMBER… These are just key points that I could recollect at this point.


The 4 badges are as follows:
  • Apex Specialist
  • Data Integration Specialist
  • Lightning Component Framework Specialist
  • Advanced Apex Specialist.
I would recommend completing these badges with 100% honesty. You will learn a lot from them.
Keep learning. Keep yourself updated with salesforce’s new features. Take all your time, go easy and keep learning.

Why to use Database.Stateful()?

Database Stateful is interface. It is used in batch classes to maintain the state of the class across transactions i.e. if you want to use ...