Skip to main content


Showing posts from September, 2020

Filter any report by current Logged In User in Salesforce | Salesforce Tutorials | Salesforce Development

Filter any report by current Logged In User in Salesforce | Salesforce Tutorials | Salesforce Development

In this article you will learn to use Running User to filter report by current Logged In user. In my case I am having a report with a user Id field in which I am storing the user's id. That report is available on each user's dashboard. Now the requirement is to display only current user's record on this report. I.E. if user "A" is logged in so he should see only his records on that report.
By default it is not possible to filter a report by the current user. But there is a workaround available for that : Create a formula field on your object which must be having User's lookup field.Datatype : Formula(18,0)Formula : If(User_lookup__c= $User.Id,1,0)Create a report with field criteria where Your_Field__c= 1The above field will be try whenever the User_lookup__c and the Running User values will be true.
If you have any question please leave a comment below. If you would like to add something to this post please leave a comment below. Share this blog with your friends …

Gantt Chart with Colorful Bars in Salesforce Lightning | #SalesforceDevelopment #GanttCharts

In this blog you will learn to create Gantt Charts in Salesforce Lightning. We will use Google Gantt Chart script and we will customize it to display Gantt Chart dynamically in our Salesforce Org.
Please follow the code below : 
GanttChart.vfp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88<apex:pagecontroller="GanttChartCtrl"><apex:form><html><head><script type="text/javascript"src=""></script><script type="text/javascript"> google.charts.load('current', {'packages':['gantt']}); google.charts.setOnLoadCallback(drawChart); function daysToMilliseconds(days) { ret…

Trigger to get Opportunity count on Account on after insert, after delete and after undelete in Salesforce

In this article I will create a Trigger on Opportunity to get count of total opportunities on Account. To store the count I have created a custom field on Account "TotalOpp__c" datatype "Number".  I will create the trigger on after insert, after delete and after undelete of Opportunity.The after undelete trigger event only fires for the following objects:AccountAssetCampaignCaseContactContentDocumentContractCustom objectsEventLeadOpportunityProductSolutionTaskPlease follow below trigger code : 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25trigger getRelatedOpportunitiesCount on Opportunity (after insert, after delete, after undelete){ Set<Id> accID =new Set<Id>(); if(Trigger.isInsert || Trigger.isUndelete){ for(Opportunity opp : Trigger.New){ accID.add(opp.AccountId); } updateAcc(accID); } elseif(Trigger.isDelete){ for(Opportunity opp : Trigger.old){ accID…

Display 🚩 Flags conditionally using formula in Salesforce Lightning

In this article I will share an example to display Flag images based on a formula value. In my case the requirement was to display flags on lead based on user's login time. Let say if user is checking the lead in between 08:00 AM EST to 05:00 PM EST so the formula should show Green flag and user can call the client.But if user is logged in after his working hours then it should show 🚩 Red flag to indicate user that he/she can not call the client at the moment.To accomplish the functionality I created a formula field with return type TEXT on Lead object and applied below formula to do the trick.
Formula1 2 3 4IF((HOUR(TIMENOW())-4)>7&& (HOUR(TIMENOW())-4)<17, IMAGE("/img/samples/flag_green.gif", "Green Flag"), IMAGE("/img/samples/flag_red.gif", "Red Flag") )
In the above formula I am using TIMENOW() to get the current time and HOUR() to get the hour only from the TIMENOW() function. The result will be in GMT so to conver…

Client Side Search in Lightning Data Table in Lightning Component Salesforce

In this article I will implement the Client Side Search functionality in Lightning Data Table in a Custom Lightning Component.Client Side Search allows user to search the data from the page itself. You don't have to query records each time, because using client side search we can use the on page database. #Salesforce #LightningComponent #DataTable
Check the code below
Component 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22<aura:componentcontroller="LightningDTCTRL"implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"access="global"><aura:attributename="recordList"type="List"/><aura:attributename="allData"type="List"/><aura:attributename="columns"type="List"/><aura:attributename="sortedBy"type="String"d…

Understand Queueable Apex with Example and Test Class | #Salesforce

Queueable Apex is similar to @future methods. It is an asynchronous apex method. It allows you to submit jobs for asynchronous processing with some additional benefits comparing to @future methods.Benefits : Queueable apex supports non-primitives like SObject and custom Apex types.We can monitor the status and progress of Queueable method using the returned Id of AsyncApexJob.We can chain one job to another by starting the second job from a running job.Limitations :  It shares limits of async Apex & Governor Limits.In a single transaction you can add maximum 50 jobs in the queue.While chaining jobs, only one child job can exist for each parent job.
Below example is taken from the Queueable Apex trailhead, the purpose of this is just to share a example of Queueable Apex with test class.
Requirements Create an Queueable Apex class that inserts Contacts for Accounts. Create a Queueable Apex class that inserts the same Contact for each Account for a specific state. Write unit tests that ac…

Get selected Picklist display text in Lightning Component #Salesforce

In this article you will learn to get the selected Picklist display text in a Lightning Component. You can easily get the selected value by using component.find("aura:id").get("v.value"); OR you can directly get the value using component.get("v.picklistValue");But what if you need the display text instead of value ?Check below example to get the selected value's text from a picklist using the index in it.Component1 2 3 4 5<lightning:selectaura:id="selectPicklist"value="{!v.Plv}"onchange="{!c.handleChange}"><aura:iterationitems="{!v.Options}"var="item"indexVar="index"><optionvalue="{!item.key}"selected="{!item.key==v.Plv}">{!item.value}</option></aura:iteration></lightning:select>
Controller1 2 3 4 5var myValues= component.get("v.Options"), value = component.find("selectPicklist").get("v.value"), …