Salesforce provides couple of developer related objects which are very useful when a developer wants to fetch the metadata information of apex class, components, pages, triggers, code coverage using apex code. There are lot of scenarios where we can utilize these objects :- To search any referenced fields and objects inside apex classes,pages & triggers….
Category: APEX
What is Dynamic Apex in Salesforce and how to use it ?
Dynamic apex enables developers to create more flexible applications by providing them with the ability to “Access sObject and field describe information”, “Write Dynamic SOQL Queries”, “Write Dynamic SOSL Queries” and “Dynamic DML”. It consists of several components such as schema describe, dynamic SOQL, dynamic SOSL, and dynamic DML. 1) Access sObject and field describe…
How to write test class for Batch Apex in Salesforce ?
We should always test batch class with good amount of data (minimum 200 records) in our test class. Here is the example of batch apex testing. In below code, we are updating name of all accounts with “Updated” keyword in the last of account name. Batch Class: global class AccountUpdate implements Database.Batchable { global Database.QueryLocator…
Making Callouts for Long-Running requests using Continuation object in Salesforce ?
Sometimes we may encounter webservice callouts in business scenarios that will take longer to respond. This is because the other end need to do significant amount of work prior to responding back. if the other end process huge number of transactions during peak loads, the response will be even slower. Salesforce has a governor limit of maximum of 10…
How to Disable or Delete an Apex Trigger or Class from Production Organization ?
Apex code can’t be modified directly within a Production organization, so it requires steps using Developer tools, like the Force.com IDE. Steps to Remove or Disable Apex Classes/Triggers 1. Force.com IDE should be installed. 2. Connect to the Production Instance using the IDE and find the class or trigger that you want to delete. 3. Open…
What is the purpose of @future method in Salesforce? How can we implement @future method?
In Salesforce usually we write a trigger for an object, and then from the trigger we call a method on a class. If we need to make call out to an external web service from the trigger we get “System.CalloutException: Callout from triggers are currently not supported”. @future method with callout=true is the way to…
How do we write a Batch Class in APEX and schedule it to run?
Scenario We need to look at all Accounts and update the related Contacts description with Rating field from respective Account. e.g. “Account rating is Cold” Why Batch Apex ? Batch Apex is used to process high volume of records and it allows us to run their code on a specific time. In batch APEX there is the…
How to write APEX Triggers and What are the best practices?
Apex triggers allows you to perform some actions when any record is created, updated, deleted or undeleted in Salesforce. What can we do using triggers? A trigger can perform following actions: Insert, Update, Delete records. Update fields from child to parent and vice-versa. Send Emails to record owner, external user, contact & lead etc. Call…
How can we handle Approval Process using APEX?
Approval process is an automated process which is used to submit, approve and reject records in Salesforce. It specifies the steps necessary for a record to be approved and who must approve it at each step. We can configure approval process from Salesforce, and then use APEX to submit, approve or reject the record. Automatic Submission of Record for Approval…
How can we Insert, Update and Delete a record in a Visualforce Page ?
We can do simple Insert, Update and Delete in a Visualforce Page with out using any APEX code. If you want extend the standard methods, you will need to write an extension to the Standard Controller or create a Custom Controller. Simple INSERT, UPDATE, DELETE in Visualforce page: We can insert, update and delete records by using…