Year: 2019

All About Asynchronous Apex

While studying for the Salesforce Platform Developer II certification, I was going through the different options Apex provides to run Apex code asynchronously. This post is all about sharing the study notes with key points to remember.Apex provides four options to run code asynchronously. Future Method, Queueable Apex, Batch Apex and Scheduled Apex.Future MethodsMethods are annotated with @future annotation.Future methods should be static and can only return void type.It supports parameters, but parameters should be primitive data types, arrays of primitive data types, or collection. sObjects or objects cannot be used as parameters to future methods.These methods run in their own thread and will only start when the resources are available.They are used for long running operations and prevent any delay in apex transaction.They can be used for callouts to external web services and also separating DML operations to prevent Mixed DML error.Future methods should not be used for processing large amount of data. In that case, Batch Apex should be used.To test future methods, enclose test code between startTest and stopTest test methods.Future methods not necessarity execute in the same order as they are called.Future methods cannot be used inside Visualforce controllers getter, setter, constructor methods.Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htmhttps://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_future_methodsQueueable ApexApex code must implement Queueable interace.By implementing Queueable interface, Apex class can be added to the job queue and it will run when the system resources are available.The difference between Queueable Apex...

Read More

Important points to remember regarding actionRegion, actionFunction, actionSupport, actionPoller

Last night(July 17th, 2019) while preparing for Platform Developer II certification, I was going through my notes to revise the different ways to call Apex Controller functions from Visualforce page, I thought of making a post regarding actionRegion, actionFunction, actionSupport, actionPoller & actionStatus. Just setting the expectation beforehand – It is not a post which will explain you all, but I will share the developer guide link for each of them so that you can go and read them (highly recommended).actionRegionThe specifies the components to be processed on Force.com server. Without this tag, the whole page will be processed. With actionRegion also the whole form is submitted, but only the part within the tag will be processed.It needs a reRender attribute to be effective. It will only refresh the part of the page using the data contained within the tag. This can be very effectively used to avoid validation errors that may occur due to present of standard validation rule in VF page like required attribute.Here is the example without ActionRegion:Controller:public with sharing class WithoutActionRegionController { public String valueEntered{get;set;} public String country{get;set;} public String state{get;set;} public WithoutActionRegionController() { country = ”; state = ”; valueEntered = ”; } public PageReference countrySubmitted(){ valueEntered = ‘Country: ‘ + country; return null; }}Visualforce Page:<apex:page controller=”WithoutActionRegionController”> <apex:form id=”myForm”> <apex:pageMessages id=”messages1″/> <apex:pageBlock id=”topPageBlock”> <apex:pageBlockSection columns=”2″ title=”Country & State”> <apex:outputText value=”Enter Country” /> <apex:inputText value=”{!country}” > <apex:actionSupport...

Read More

Advanced Currency Management in Salesforce

Salesforce supports multi currency. You can enable the same by going to Company Information and then checking the box – “Activate Multiple Currencies”. You need to read the below article before enabling multi currency. https://help.salesforce.com/articleView?id=admin_enable_multicurrency_implications.htmOnce done, you can enable Dated Exchange Rate to define the exchange rate for any kind of periods like month, quarter, year etc. To do that you can go to Company profile -> Manage CurrenciesNow you can add the entries for dated exchange rates by clicking on the “Manage Dated Exchange Rates” button. And then click on “New Exchange Rates” button. Below images shows how to add dated exchange rates.This dated exchange rates are used in Opportunities, Opportunity products and Opportunity Reports.The object used to store this information is DatedConversionRate. You can run SOQL queries against this object to get the details -SELECT IsoCode,ConversionRate,NextStartDate,StartDate FROM DatedConversionRate ORDER BY NextStartDate ASCYou can use Rest Explorer also to add/delete new DatedConversionRate like below -Important Objects/Fields:CurrencyType: This object stores the list of currencies used in the org when multi currency is enabled. If single currency is used in the org, then this object is not available.DatedConversionRate: This object stores the dated exchange rates.CurrencyIsoCode: This additional field is present in object which has current field and the org has multi-currency...

Read More

Summer’19 : Celebrate Sales Milestones with Path

In Summer 19 release, Salesforce introduces a new cool feature so that you can let your user celebrate when they reach certain stages in Sales path(or any path). This is a fun, visual way of celebrating success right from the Salesforce screen.This idea came from an old blog post regarding building with path based component, where community liked the idea and Salesforce delivered this to us now. To me this is the power of Salesforce community.So let’s configure this together -Step 1Enable path in your org.Step 2Click on New Path. Choose values as shown in the below screenshot. (You can select any values available).Step 3Click on Next and ant the next screen select Key fields for the Opportunity Stages. Click on Next.Step 4At this stage, enable on-screen confetti.Step 5Here, you can select which stage you want top celebrate. Select those picklist values. Also you can select the frequency of celebration. And finally click on Finish. That’s all you need to do to get this new cool feature.Here is the video with step by step instructions...

Read More

Kitchener Canada Developer Group Event: Introduction to DevOps with Salesforce DX by René Winklmayer

Special thanks to our speaker, René Winklmayer, for the session on Introduction to DevOps with Salesforce DX.Here comes the presentation and recording.Presentation: Kitchener Salesforce Developer Group Event – Introduction to dev ops with SalesforceDx from Sudipta Deb ☁ Recording: Please register to Kitchener, Canada Developer Group for all our future...

Read More

Understanding JavaScript Promises

Dealing with asynchronous code? Promises is the way to deal with it without writing multiple callbacks. Promises were standardized and introduced in ES2015, but in ES2017 they have been superseded by async function. Understanding of Promises is the foundation of learning Async functions.

Read More

Earlier Posts

  • 2024 (25)
  • 2023 (47)
  • 2022 (25)
  • 2021 (35)
  • 2020 (41)
  • 2019 (13)
  • 2018 (16)
  • 2017 (14)
  • 2016 (18)
  • 2015 (74)
  • 2014 (20)