Skip to content

Instantly share code, notes, and snippets.

View mhamzas's full-sized avatar

Hamza Siddiqui mhamzas

View GitHub Profile
@mhamzas
mhamzas / SampleController.js
Last active November 19, 2019 07:59
Custom Case Deflection in Lightning Community [aura]
({
itemsChange : function(component, event, helper) {
var appEvent = $A.get("e.selfService:caseCreateFieldChange");
appEvent.setParams({
"modifiedField": event.getSource().get("v.fieldName"),
"modifiedFieldValue": event.getSource().get("v.value")
});
appEvent.fire();
})
@mhamzas
mhamzas / New Form
Created November 20, 2019 20:37
Weldtech Request Form
<form name="formcontact33" id="formcontact33" action="https://go.weldtechtraining.com/l/705123/2019-05-09/2nt3" method="POST">
<div id="thanks" style="display:none;" class="thanku-div">
<p id="thanku">Your form is succsessfully submited. Thanks!!! </p>
</div>
<div id="thanks1" style="display:none;" class="thanku-div">
<p id="thanku">Oops!!!! Your form is Not submited. </p>
</div>
@mhamzas
mhamzas / InvocableMethod.cls
Last active April 28, 2023 15:47
Apex Invocable Class with multiple variables/parameters
global class InvocableMethodcls {
/*An invocable variable used as input or output variables in the process builder*/
global class ActionRequest {
@InvocableVariable(required = true)
public ID leadId;
@InvocableVariable
public String phone;
@mhamzas
mhamzas / sObjectUpsert.cls
Created December 13, 2019 07:23
Upserts with Generic sObjects - Salesforce
list < sObject > sObjList = new list < sObject > (); //This routine would get the rows to update/insert from some business logic
sObjList = myClass.getObjectRowsToUpdate();
set < string > newExtIDSet = new set < string > ();
string myExternalIDField = 'myExternalID__c'; //Loop through and build a set of External IDs that should be used for a query
for (sObject sObjItem: sObjList) {
tempStr = string.ValueOf(sObjItem.get(myExternalIDField));
if (string.isBlank(tempStr) == false) {
newExtIDSet.add(tempStr);
}
@mhamzas
mhamzas / SupportTicketEmailService.cls
Created December 26, 2019 08:06
Email services handler to process incoming emails to our support email address and create a Support_Ticket__c record in Salesforce automatically, with related activities and attachments.
global class SupportTicketEmailService implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,Messaging.InboundEnvelope envelop){
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
//Instantiate email variables
String fromName = email.fromName;
String emailBody = email.plainTextBody;
String subject = email.Subject;
String fromAddress = email.fromAddress;
@mhamzas
mhamzas / AutoCaseSharing.trg
Created January 3, 2020 16:20
This Trigger will share the newly created case i.e. S2S.
/*
* Trigger Name : AutoCaseSharing
* Author : Hamza @ CloudJunction
* Date Creation : 10/15/2018 01:29 GMT+5
* Last Date Modified : 10/15/2018 02:31 GMT+5
@mhamzas
mhamzas / getinputval.js
Created January 17, 2020 07:11
Custom validation in Lightning web component
/* Method to get input field value */
getinputval() {
let returnvalue; //assigning temp variable
var inputCmp = this.template.querySelector(".inputfield"); //getting element
var value = inputCmp.value; //assigning value to variable
// is input valid text?
if (value === "") {
//adding custom validation
inputCmp.setCustomValidity("Field is Required!");
returnvalue = false;
@mhamzas
mhamzas / IsCanadianSIN.cls
Created March 27, 2020 09:05
Canadian SIN Checksum Checker - Apex Method
// Canadian SIN Checksum Checker
// Source: https://stackoverflow.com/questions/4263398/how-do-i-check-the-validity-of-the-canadian-social-insurance-number-in-c
@AuraEnabled(cacheable=true)
public static boolean IsCanadianSIN(string sSIN){
Integer iChecksum = 0;
Integer iDigit = 0;
// Checking if number is not starting with 9
if(!sSIN.startsWith('9')){
@mhamzas
mhamzas / FSC Record Creation
Created April 6, 2020 14:48
Public Rest service to insert Financial Account and Financial Account Transactions
@RestResource(urlMapping='/DLResult')
global without sharing class DL_Info_Receiver {
@HttpGet
global static void doGet() {
RestContext.response.addHeader('Content-Type', 'text/plain');
String code = RestContext.request.params.get('rc');
String CustomerId = RestContext.request.params.get('customerid');
RestContext.response.responseBody = Blob.valueOf('Hello '+CustomerId);
String Message;
List<sObject> records = new List<sObject>();
records.add(new Account(AccountExternalId__c='1234555', Name='ABCD Company'));
records.add(new Contact(account=new Account(AccountExternalId__c='1234555'),lastname = 'Testlast', ContactExternalId__c='3525'));
records.add(new AccountContact__c (Contact__r = new Contact(ContactExternalId__c='3525')));
insert records;