Skip to content

Instantly share code, notes, and snippets.

View mhamzas's full-sized avatar

Hamza Siddiqui mhamzas

View GitHub Profile
@mhamzas
mhamzas / confettiComponent.html
Created September 6, 2019 12:46
Confetti & SweetAlert in Lightning Web Component
<template>
<p>Confetti and Sweet alert demo using LWC component</p>
<canvas class="confettiCanvas" id="canvas" lwc:dom="manual"></canvas>
<lightning-card title="Sweet Alert">
<lightning-button
label="Success"
onclick={showSuccessAlert}
variant="success"
@mhamzas
mhamzas / General Trigger Pattern
Last active September 27, 2019 14:59
General Trigger Pattern
trigger someTrigger on MyObject__c (before|after insert|update|delete){
// Declare a collection to hold values we want to query against
Set<Id> myIdsSet = new Set<Id>();
// Iterate over a collection of objects, and gather the values we want to query
// against
for(MyObject__c myObj :trigger.new){
myIdsSet.add(myObj.someLookup__c);
}
@mhamzas
mhamzas / RollupAssetsonAccount.trg
Last active October 21, 2019 13:32
Rollup Asset Product Names on Account Object in MultiPickList - See the Updated here : https://gist.github.com/mhamzas/bff2c2115a23350289e1e2bbfa2766c5
trigger RollupAssetsonAccount on Asset (after insert, after update) {
RollupassetsonAcc_TrgHandler handler = new RollupassetsonAcc_TrgHandler();
// After Insert
if(Trigger.isInsert && Trigger.isAfter)
{
handler.onAfterInsert_Asset(Trigger.new, Trigger.newMap);
}
@mhamzas
mhamzas / SignatureHelper.cls
Created October 4, 2019 18:57
Capture Signature using HTML5 Canvas inside Salesforce Lightning Web Component [Salesforce Files]
public with sharing class SignatureHelper {
@AuraEnabled
public static void saveSign(String strSignElement,Id recId){
// Create Salesforce File
//Insert ContentVersion
ContentVersion cVersion = new ContentVersion();
cVersion.ContentLocation = 'S'; //S-Document is in Salesforce. E-Document is outside of Salesforce. L-Document is on a Social Netork.
cVersion.PathOnClient = 'Signature-'+System.now() +'.png';//File name with extention
@mhamzas
mhamzas / ParentFileSharing.cls
Created October 11, 2019 11:11
Share file with Parent Record.
/*
*
* Author : M Hamza Siddiqui
* Description : Share file with Parent Record.
* Last Modified : Oct 1,2019
*
*/
trigger ParentFileSharing on ContentDocumentLink (before insert) {
List<ContentDocumentLink> linksToAdd = new List<ContentDocumentLink>();
@mhamzas
mhamzas / salesforce.php
Last active October 20, 2019 00:36
Simple PHP Script to Test Email2Case
/*
Author : M Hamza Siddiqui
Description : Simple PHP Script to Test Email2Case, Both methods are provided.
Date : Aug 2015
*/
<html>
<head>
<title>Email2Case Generator
</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
@mhamzas
mhamzas / RollupassetsonAccTrg.trg
Last active October 21, 2019 13:44
Rollup Asset Product Names on Account Object in MultiPickList - [NEW]
trigger RollupassetsonAccTrg on Asset (after insert,after update,after delete) {
RollupassetsonAcc_TrgHandler handler = new RollupassetsonAcc_TrgHandler();
handler.RollupAssets(Trigger.new, Trigger.newMap, Trigger.old,Trigger.isDelete);
}
@mhamzas
mhamzas / Web2Case.html
Created November 5, 2019 12:59
Salesforce Web to lead and Web to Case using Javascript [CORS Proof !]
<script type="text/javascript">
// Case Data preparation
var postData = {
oid: '00D0b000000xxxx', //Put your ORGID here
name:'John Smith',
company:'ACME',
email:'[email protected]',
origin:'Web',
subject:'Web2Case using the custom API',
@mhamzas
mhamzas / my.cnf
Created November 9, 2019 20:29 — forked from oinume/my.cnf
my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
@mhamzas
mhamzas / caseContact.cmp
Created November 18, 2019 14:17
Contact Support Custom AURA - Clearbanc
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
<aura:attribute name="SubmitBtnLabel" Type="String" default="Submit" />
<aura:attribute name="CreateCaseBtnLbl" Type="String" default="Create Case" />
<aura:registerEvent name="appEvent" type="selfService:caseCreateFieldChange"/>
<lightning:recordEditForm aura:id="recordEditForm"
objectApiName="Case" onsuccess="{!c.handleSuccess}">
<lightning:messages />