Skip to content

Instantly share code, notes, and snippets.

View jagmohansingh's full-sized avatar

Jagmohan Singh jagmohansingh

View GitHub Profile
@jagmohansingh
jagmohansingh / CustomAlert.cmp
Last active October 30, 2023 07:58
CustomAlert
<aura:component >
<aura:attribute name="title" type="String" />
<aura:attribute name="message" type="String" />
<aura:attribute name="showConfirmButton" type="Boolean" default="true" />
<aura:attribute name="showCancelButton" type="Boolean" default="false" />
<aura:attribute name="confirmButtonLabel" type="String" default="OK" />
<aura:attribute name="cancelButtonLabel" type="String" default="Cancel" />
<!-- accepting user input -->
<aura:attribute name="inputType" type="String" />
@jagmohansingh
jagmohansingh / ProfilePhoto.cmp
Last active October 6, 2023 16:21
Lightning component to get, set and delete community user profile photo
<aura:component implements="forceCommunity:availableForAllPageTypes" controller="ProfilePhotoCtrl" access="global">
<aura:attribute name="photo" type="Object" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
<lightning:card class="slds-p-horizontal_medium">
<lightning:spinner aura:id="spinner" />
<aura:if isTrue="{!empty(v.photo) == false}">
<div class="c-profile-img">
@jagmohansingh
jagmohansingh / DeletePhotoCtrl.cls
Created September 30, 2023 10:01
Community User Photo Methods
public with sharing class DeletePhotoCtrl {
@AuraEnabled @RemoteAction
public static Map<String, Object> deleteCommunityUserPhoto() {
Map<String, Object> result = new Map<String, Object>();
try {
// get logged in user id
String userId = UserInfo.getUserId();
// get community id
String networkId = Network.getNetworkId();
@jagmohansingh
jagmohansingh / LoadRecordsCtrl.cls
Last active October 31, 2022 06:23
Server-side pagination using Apex on large datasets
public class LoadRecordsCtrl {
@RemoteAction
public static Map<String, Object> fetchRecords(String sObjectName, String lastKnownId, Integer pageSize, Integer direction) {
Map<String, Object> result = new Map<String, Object>();
try {
SObject sObj = (SObject) Type.forName(sObjectName).newInstance();
Integer totalRecords = SObjectQueryService.getTotalCount(sObjectName);
Integer totalPages = (Integer) Math.ceil((Decimal) totalRecords / pageSize);
Integer maxResults = pageSize;
@jagmohansingh
jagmohansingh / SaveDOMToImage.vfp
Last active March 19, 2021 12:16
Save DOM As Image Attachment - Visualforce
<apex:page standardController="Account" extensions="SaveDOMToImageCtrl" docType="html-5.0">
<!-- load domtoimage JS library -->
<apex:includeScript value="{!$Resource.DomToImage}" />
<style type="text/css">
#image_data {
border: red 2px solid;
background-color: white;
}
@jagmohansingh
jagmohansingh / CaseCommentHelper.cls
Created November 30, 2020 16:54
Assign Entitlement Process To Incoming Cases And Mark Milestones As Completed
// case comment trigger helper class
public with sharing class CaseCommentHelper {
public static void handleFirstResponse(List<CaseComment> comments){
DateTime completionDate = System.now();
List<String> caseIds = new List<String>();
for (CaseComment cc : comments){
// Only public comments qualify
if(cc.IsPublished == true) caseIds.add(cc.ParentId);
}
@jagmohansingh
jagmohansingh / CreateQuote.cmp
Last active April 11, 2021 06:11
Create Quote using Opportunity Lightning Action
<aura:component controller="CreateQuoteController" implements="force:hasRecordId,force:hasSObjectName,flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader" access="global" >
<aura:attribute name="recordId" type="String" />
<aura:attribute name="defaults" type="Object" />
<aura:attribute name="editSection" type="List" />
<aura:attribute name="readSection" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:notificationsLibrary aura:id="notificationsLibrary" />