Skip to content

Instantly share code, notes, and snippets.

View dhaniksahni's full-sized avatar

Dhanik Lal Sahni dhaniksahni

View GitHub Profile
@dhaniksahni
dhaniksahni / EmailService.apxc
Created April 8, 2020 11:57
Email Service in Apex
public class EmailService {
public string subject{get;set;} // mail subject
public List<String> toAddresses{get;set;} // send to
public List<String> CCAddresses{get;set;} // cc
public String body{set;get;} // mail plain body
public string displayName{set;get;} // from
public boolean isAttachment {set;get;} // if we have to send attachment file in mail
public Map<String,String> attachFiles {set;get;} // key = attachmentName and value =attachmentBody
public boolean isHtml{set;get;}
public List<Messaging.EmailFileAttachment> attachments;
@dhaniksahni
dhaniksahni / WhatsAppMessageService.apxc
Last active June 29, 2023 12:10
Twilio WhatsApp Message Integration in Salesforce Apex
public class WhatsAppMessageService {
@AuraEnabled
public static void sendMessage(string mobileno,string message)
{
errorResponseWrapper erw;
final String fromNumber = '+14155238886';
String account = 'ACa2e448aaa0e51ed81a56ff55b6635cca';
String token = '<your token>';
HttpRequest req = new HttpRequest();
@dhaniksahni
dhaniksahni / SingleSelectDatatable.js
Created August 16, 2020 19:07
Single Row Selection in LWC
import { LightningElement, wire } from 'lwc';
import getContactList from '@salesforce/apex/ContactController.getContactList';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
const columns = [
{ label: 'First Name', fieldName: 'FirstName' },
{ label: 'Last Name', fieldName: 'LastName' },
{ label: 'Title', fieldName: 'Title' },
{ label: 'Phone', fieldName: 'Phone', type: 'phone' },
{ label: 'Email', fieldName: 'Email', type: 'email' }
@dhaniksahni
dhaniksahni / HttpCallout.apxc
Created May 10, 2020 13:05
Page Layout Information in Apex
public class HttpCallout {
public static String restGet(String endPoint, String method, String sid) {
try
{
Http h = new Http();
HttpRequest hr = new HttpRequest();
hr.setHeader('Authorization', 'Bearer ' + sid);
hr.setTimeout(60000);
hr.setEndpoint(endPoint);
@dhaniksahni
dhaniksahni / fileUploader.cmp
Last active May 7, 2022 08:40
Multiple File Upload using Lightning Component
<aura:component controller="FileUploadController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<!--Record Id of current object where this component will be added. -->
<aura:attribute name="recordId" type="Id" />
<!--Showing spinner while uploading -->
<aura:attribute name="showLoadingSpinner" type="boolean" default="false" />
<aura:attribute name="fileName" type="String" default="No File Selected.." />
<!--List of file which are uploaded -->
<aura:attribute name="FilesUploaded" type="List" />
<div class="row">
<div class="slds-grid slds-gutters">
@dhaniksahni
dhaniksahni / smsSender.html
Created March 7, 2020 14:33
SMS Sender in Lightning Web Component
<template>
<lightning-card title="SMS Sender" icon-name="standard:action_list_component">
<div class="slds-grid slds-grid_vertical">
<div class="slds-col slds-size_1-of-1">
<lightning-input type="text" name="mobileNumber" data-id="mobileNumber" label="Enter Mobile Number"></lightning-input>
</div>
<div class="slds-col slds-size_1-of-1">
<lightning-input type="text" name="smsBody" data-id="smsBody" label="Enter SMS Message"></lightning-input>
</div>
<div class="slds-col slds-size_1-of-1">
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: Base Exception for throwing error in code.
*/
public class BaseException extends Exception {
}
public class S3Controller {
@AuraEnabled
public static void UploadDocToS3Server(string recordId)
{
UploadDocument(recordId);
}
@future(callout=true)
public static void UploadDocument(string recordId)
{
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: AWS Service for uploading file
*/
public class AWSService {
public string awsKey {get;set;}
public string awsSecret {get;set;}
@dhaniksahni
dhaniksahni / captureImageWebCam.cmp
Last active April 7, 2021 19:56
Capture Image using WebRTC in Lightning Component
<aura:component controller="ImageController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<lightning:card title="Capture Screen">
<lightning:layout horizontalAlign="spread">
<lightning:layoutItem padding="around-small">
<h1>
MDN - WebRTC: Still photo capture demo
</h1>
<div class="camera">
<video id="video">Video stream not available.</video>
<button id="startbutton" onclick="{!c.doInit}">Take photo</button>