Posts

Showing posts with the label Development

Zip or Unzip Files in Salesforce

Image
Hello Trailblazers, Though Salesforce provides wide variety of out of the functionalities, in house solutions – creating a zip file or unzipping it in apex is still something that is not provided by Salesforce. For one of my work I came across situation where I wanted to zip multiple files together and I couldn’t find anything through Salesforce documentations. After spending some time over internet, I came across few workarounds which can be used to create zip files in Salesforce.  Listing down three of them for three different platform solutions. Zippex Utility This is Apex based utility which can help you to zip files along with other useful operations. This utility code developed by Pedro Dal Col & Pliny Smith is available on GitHub and you can deploy it’s components directly to you org as well. As per me this utility is very much powerful as it provides unzip feature as well. You can have folder structure as well or you can club multiple individual files as well using Zi...

Salesforce - JWT Bearer Flow for Authentication

Image
Hello Trailblazers,  In this blog we are going to focus on OAuth 2.0 JWT Bearer Flow for Server-to-Server Integration. JWT Bearer Flow is used for server to server communication and to avoid logging in each time.  JWT Bearer Token is something that you provide to some other service to let that service authenticate you. This flow uses a certificate to sign the JWT request and doesn’t require explicit user interaction. However, this flow does require prior approval of the client app. Which means you need to allow access first for the connected app by using some third-party authorization app. So, we can consider JWT as a key which gives us access to various things. Pre-requisites for JWT(JSON Web Token) Bearer Flow X509 certificate Connected App X509 certificate  Since we will be signing JWT using RSA SHA256, we need certificate as a secret for signing data. You can download certificate from Salesforce or you can use openssl for ge...

Scan barcodes from Salesforce Mobile App

Image
Hello Trailblazers, Today I am going discuss a newly added functionality to Salesforce Mobile platform which has given us ability to scan the barcodes from salesforce mobile app using Lightning Web Component implementation. With the help of this Barcode Scanner API we can now read UPC, QR and other type of barcodes from Lightning Web Component.  This API is made generally available by Salesforce after February 2022. Lightning Web Component uses your mobile camera and mobile OS capabilities to scan the barcode and then sends data back to LWC from where process was invoked. You can use any UI(Button, link etc.) to start barcode scanning. So, the general flow will be initiate barcode scanning from lightning web component then mobile camera will be opened and once valid barcode is scanned you will be returned to your lightning web component which initiated this scan with data which you can process. BarcodeScanner API This barcode scanner API has capability to scan single barcode as wel...

Salesforce Lightning empAPI Module - Test Platform, CDC Events

Image
  Hello Trailblazers, In this blog I have explained use of EMP API which is used to subscribe for events. You can create Lightning Component which uses this EMP API for subscribing to various streaming channels such as Platform Events, Change Data Capture Events, Generic Events. We can use this implementation for testing Platform Events or Change Data Capture events in local environment. Lightning/empApi module has below methods which are used for implementing events subscription.  Method Name    Parameter Name  Description  subscribe    Subscribes to the streaming channel, this gives subscription object which we use to unsubscribe later.    onMessageCallback  Callback function which is invoked whenever an event is received    repla...

Salesforce External Services

Image
Hello Trailblazers,   Today we will discuss about another no/low code feature of Salesforce – External Services. Whenever delivering an application if you can provide 360-degree view of products or services on a single platform then it becomes important factor which can affect customer satisfaction in positive way. And integrations help us in achieving the same by allowing us to connect to various services to get data or process data. In traditional approach we were using apex classes to implement REST integration with the help of endpoints and other necessary details. But Salesforce has now come up with External Services with the help of which you can connect your Salesforce Org to any RESTful service with the help of API Specification. So now onwards whenever you have to call any external web service just perform below steps and you will be able to connect your org without any code – Get API Specification File* from web service provider Create Named Credentials Register your...

Salesforce Hierarchy Custom Settings : Fair Use

Image
  Hello Trailblazers,   Today I am going to discuss about one functionality of Salesforce that everyone knows but still very few use it in correct way. We have been using Custom Settings for storing static values for global use and avoid hard coding, but I believe most of us use List type Custom Settings only. I am going to explain Hierarchy Custom setting and it’s actual/appropriate use in this blog. So first let us quickly understand what custom settings are – Custom Settings are just like Custom Objects in Salesforce which enable us to create custom sets of data that can be accessed in formula fields, validation rules, apex, flows & SOAP API without consuming an extra query for retrieval. There are two types of custom settings: List & Hierarchy. What is Hierarchy Custom Setting? Hierarchy Custom Settings does the same job done by List Custom Settings but with an additional power of managing data as per built-in hierarchical logic that let’s you decide what dat...

Salesforce Platform Events

Image
Hello Trailblazers, In this article we will discuss about the platform events. This covers basic idea of Platform Events, how platform events work, how to use Platform Events and some considerations for using Platform Events. Salesforce Platform Events follow Event Driven Architecture. So what is event driven architecture? In simple words, whenever any kind of action happens you notify someone with some message, and we call that action as an Event , message that it carries is known as Event Message , someone who is going to receive that message is known as Event Consumer , environment where action has happened is Event Producer and common channel through which Producer sends an event and receiver reads message is known as Event Bus . This is completely different from request-response structure, your system/application just have to subscribe to event channel and they will be notified in real-time whenever event occurs. Receivers are always in listening mode and more than one receive...

VS Code Editor Setup For Salesforce

Image
Visual Studio Code is the latest IDE for Salesforce Development and believe me it has eased developer’s life by providing rich functionalities. This post will help you to setup VS code editor for Salesforce development.  Downloads : 1.        Visual Studio Code 2.        Salesforce CLI Installing VS Code Editor To download Visual Studio Code navigate to link given above. From download page select your operating system and proceed to download. I will suggest you to download most stable version of VS Code Editor. Once download is complete, install it in the system. Once installation is complete, you’ll see below welcome screen. While installing make sure to select Add To PATH option. Now let’s go ahead and download Salesforce CLI.   Installing Salesforce CLI Salesforce CLI is a command line interface that simplifies development and build automation.  VS Code ...

Debugging In Salesforce - Part II

Image
Hope you have read Part I of this series !! In this part we'll understand how to read log file. Once you capture a log file and open it, you can get all information from first line itself. First line of log gives information about the log categories and levels and   Second line gives User Information EXECUTION_STARTED marks the start of transaction. CODE_UNIT_STARTED and CODE_UNIIT_FINISHED marks start and end of particular code unit which was executed during transaction. Using this you can check what has happened when particular unit of code executed. Units of code include, but are not limited to, the following: Triggers Workflow invocations and time-based workflow Validation rules Approval processes Apex lead convert @future method invocations Web service invocations executeAnonymous calls Visualforce property accesses on Apex controllers Visualforce actions on Apex controllers Execution of the batch Apex start and finish methods, and each ex...