Author: Dhanik Lal Sahni

In projects many time we need to check, user has access to read data or update data of any object’s field. We can check field access using UserFieldAccess object. In this post, i have create one lightning web component to show object and it’s fields in combox box. Another combox box is added to show users in Salesforce Org. Based on input selected, it will show field access in lightning table. If only user and object is selected then it will show user access of all fields. If user, object and field name is selected then it will show access of…

Read More

Dependent Picklist is required for most of the time in our project. This post is showing how we can create dependent list in Lightning Web Component. In this post, I have taken example of object and fields available in Salesforce Org.  Object will be master picklist  and field will be child which is populated based on object selected. Below steps are required to created dependent list. Apex class to get object and fields Create Master and Child Picklist using lightning-combobox 1. Apex class to get object and fields: To get Salesforce Org’s objects we can use Schema.getGlobalDescribe().  We can set…

Read More

Salesforce provides support for creating custom Salesforce APIs to handle business requirements. Businesses needed to update a few pieces of information in Salesforce. To handle such requirements we can use patch REST API. Client code canI call this REST API to update some of the fields in our Salesforce org. For this blog, i have taken an example for account object record update. A vendor might be updating one field at a time or multiple fields.  As it external system was involved in this API interaction, instead of sending field API name they were sending request in normal JSON request.…

Read More

Showing image in data table is one of major requirements in projects. In this post, we will see how we can show image in Lightning Web Component Data Table.  In last blog Integrate Salesforce Stackexchange using Lightning Web Component and Apex I have created community to show Salesforce StackExchange user list. Let us add profile picture of user in same community. By default datatable does not support image data type. We have to create custom data type for image in Lightning Web component. Steps for creating custom data type Custom Control Creation Extend Lightning Data Table Use extended data table in Component…

Read More

Salesforce Stack Exchange is dedicated community site for Salesforce developer to get answers of all question. This community has lot of members who helps in resolving issues.  This post is showing how we can get list of all members of this community. We are using Salesforce Stack Exchange API to get members list using Apex. Members list is being shown using Lightning Web Component in lightning community.  I have named this community as Salesforce Stackexchange User Explorer  and can be accessed at https://dhanik-stackoverflow-developer-edition.ap15.force.com/stackexplorer/s/ Salesforce Stack Exchange API : https://api.stackexchange.com/2.2/users API is used to get user list in Apex. We can pass different parameter to…

Read More

In real time projects, some time we have requirement to capture customer/user image in application processing at real time.  In this article we will see, how to capture image using lightning component. For capturing image, we can use browser’s inbuilt WebRTC functionality to access the camera on a laptop, computer or mobile phone with WebRTC support and take a photo with it. WebRTC (Web Real-Time Communications) is a technology which enables Web applications and sites to capture and optionally stream audio and/or video media, as well as to exchange arbitrary data between browsers without requiring an intermediary. We will use Media Capture…

Read More

Capturing screen of application was requirement in one of my project. We have used lightning component with Web API to capture screens. In this article, We will see the Screen Capture API and its getDisplayMedia()method to capture part or all of a screen for streaming. Capturing screen contents navigator.mediaDevices.getDisplayMedia() will capture screen content as live MediaStream . This function returns promise with live screen contents. navigator.mediaDevices.getDisplayMedia(displayMediaOptions) .then( mediaStream => { videoElem.srcObject = mediaStream; videoElem.onloadedmetadata = e => { videoElem.play(); videoElem.pause(); }; }) mediaStream containing the captured display imagery. It can be assigned on video element to show captured screen. <video id=”video” autoplay=”true”></video> Object displayMediaOptions contains the MediaStreamConstraints to…

Read More

Orthographic projection can easily be created in AmCharts. This post is to make that globe in Lightning component. As AmChart is third part library, we have to include it using Static Resource.  Download below JS files and add in Static Resource. https://www.amcharts.com/lib/4/core.js https://www.amcharts.com/lib/4/maps.js https://www.amcharts.com/lib/4/geodata/worldLow.js https://www.amcharts.com/lib/4/themes/animated.js After adding it in Static Resource, add reference in lightning component. <ltng:require scripts=”{!join(‘,’, $Resource.amcharts + ‘/core.js’, $Resource.amcharts + ‘/maps.js’, $Resource.amcharts + ‘/worldLow.js’, $Resource.amcharts + ‘/animated.js’)}” afterScriptsLoaded=”{!c.afterScriptsLoaded}” /> Creating map instance am4core.create() function is used to create of map instance. var chart = am4core.create(“chartdiv”, am4maps.MapChart); geodata property will set specific map definition. chart.geodata = am4geodata_worldLow; // Set…

Read More

New Apex Classes These classes were introduced in Winter 20 release. Formula Class in the System Namespace: The new System.Formula class contains the recalculateFormulas method that updates (recalculates) all formula fields on the input sObjects. Recalculates all formula fields on an sObject, and sets updated field values. Rather than inserting or updating objects each time you want to test changes to your formula logic, call this method and inspect your new field values. Then make further logic changes as needed. FormulaRecalcFieldError Class in the System Namespace The new System.FormulaRecalcFieldError class is the return type of the FormulaRecalcResult.getErrors method. It contains…

Read More