Usually in trigger, we work on updating related lists we end up querying sObject and looping over it. Or we also make a MAP from that list of records which will create lots of loops and iterations. To avoid this. Salesforce provide us with a simple feature where you can write a SOQL query and return MAP directly.
Continue reading “APEX: SOQL to MAP of sObject”Tag: Apex
APEX: How to check if ORG is Sandbox or Production
Recently after a major deployment, we took refresh of a sandbox org. One of the developers worked on a change request on the refreshed copy. Unfortunately, he forgot to change Named Credentials, Auth Provider, Remote site setting. After working on the change request, developer started testing the same. This resulted in record creation in third party application through API’s. There were many test records which were created in third party applications and the issue got escalated.
Continue reading “APEX: How to check if ORG is Sandbox or Production”sObject Name from RecordId in Apex Class
When working on visualforce pages, there will be a requirement to get to know the sObject name of a record on which you are working. In lightning experience, you will get to know to know the sObject directly just like recordId. But such option is not available in classic version’s visualforce pages.
Continue reading “sObject Name from RecordId in Apex Class”Get field’s lable, API name, isCustom in APEX
When working in apex, sometimes you need field’s label name and API name and other details. Below is a sample code which can be used to fetch details of any object’s field, its Label, its Name(API Name), and an attribute to check if it’s a custom field or no. There are other options too which can be referred as per business requirement.
Continue reading “Get field’s lable, API name, isCustom in APEX”Access Modifiers in Salesforce
Access modifiers are used in apex class in salesforce. Similar to Java programming, Salesforce supports 4 different access modifiers in salesforce.
- private
- protected
- public
- global