Skip to content

Instantly share code, notes, and snippets.

View mhamzas's full-sized avatar

M Hamza Siddiqui mhamzas

View GitHub Profile
@mhamzas
mhamzas / gist:9d881ad0a485f1e3e187eb1175a2d58d
Created June 15, 2022 12:34 — forked from lfreeland/gist:df5c757036e38751874f5d4b874e5a19
Lightning Field Set Form Apex Controller
public with sharing class FieldSetFormController {
@AuraEnabled
public static FieldSetForm getForm(Id recordId, String objectName, String fieldSetName) {
FieldSetForm form = new FieldSetForm();
form.Fields = getFields(recordId, objectName, fieldSetName);
form.Record = getRecord(recordId, objectName, form.Fields);
return form;
}
@mhamzas
mhamzas / Integration_BasicAuthRestCallout.cls
Created May 18, 2022 10:18 — forked from LabCoatTeam/Integration_BasicAuthRestCallout.cls
This is a quick overview of an Apex REST Callout using Basic Authentication from within Salesforce
// Method to perform callouts
public String MakeCallout(string description, string keyToVerify){
// define a response to caller
String outcomeMsg;
// define basic information for later, store these in a protected custom setting
string endpoint = 'http://api.yourendpoint.com/'; // be sure this is configured in "Remote Site Settings"
string resource = 'products/';
string username = 'api_user';
// example of how to configure SecuritySettings in your scratch org.
{
"orgName": "Acme",
"edition": "Enterprise",
"features": [],
"settings": {
"mobileSettings": {
"enableS1EncryptedStoragePref2": true
},
"securitySettings": {
@mhamzas
mhamzas / project-scratch-def.json
Created March 4, 2022 12:27
Pardot Licenses in Scratch Org
{
"orgName": "Salesforce - Dev Org",
"edition": "Developer",
"features": [
"Pardot"
],
"settings": {
"pardotSettings": {
"enablePardotEnabled": true,
"enablePardotAppV1Enabled": true,
@mhamzas
mhamzas / gist:1d6b4c26f39676fe4867e7425edac702
Last active November 6, 2022 14:07 — forked from Sunil02kumar/gist:396b9ec81b59a23aee29e5ca41a28202
Find All Content Version Ids from Library and Generate File download URLs
string LibraryName='Demo Download Library';
ContentWorkspace ws = [SELECT Id, RootContentFolderId FROM ContentWorkspace WHERE Name = :LibraryName LIMIT 1];
Set<string> fileNameList = new Set<string>();
List<ContentDocumentLink> filesToDelete= new List<ContentDocumentLink>();
string csvString='';
String domainUrl=URL.getSalesforceBaseUrl().toExternalForm();
for(ContentDocumentLink con:[select id,LinkedEntityId,ContentDocumentId ,ContentDocument.LatestPublishedVersion.Title from ContentDocumentLink where LinkedEntityId=:ws.Id]){
csvString = csvString +domainUrl+'/sfc/servlet.shepherd/version/download/'+con.ContentDocument.LatestPublishedVersionId+'\n';
}
@mhamzas
mhamzas / SandboxPostCopyUpd.cls
Created November 17, 2021 11:15 — forked from az-ak/SandboxPostCopyUpd.cls
Apex SandboxPostCopy example
global without sharing class SandboxPostCopyUpd implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
LIst<Contact> ConList = [SELECT ID FROM CONTACT];
for (Contact con : ConList) {
con.Email = 'dummy@example.com';
}
update ConList;
}
}
@mhamzas
mhamzas / ant-salesforce.xml
Created November 4, 2021 10:15 — forked from afawcett/ant-salesforce.xml
Defines some macros around sf:deploy to install and uninstall packages.
<!-- TODO: Review Ant v1.8 local properties -->
<project xmlns:sf="antlib:com.salesforce">
<!-- Download from Salesforce Tools page under Setup -->
<typedef
uri="antlib:com.salesforce"
resource="com/salesforce/antlib.xml"
classpath="${basedir}/lib/ant-salesforce.jar"/>
<!-- Download from http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ -->
@mhamzas
mhamzas / countries
Created October 7, 2021 21:51 — forked from kalinchernev/countries
Plain text list of countries
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua & Deps
Argentina
Armenia
Australia
Austria
@mhamzas
mhamzas / saveSobjectSet.cls
Created September 3, 2021 14:07
Cannot have more than 10 chunks in a single operation. Please rearrange the data to reduce chunking.
private static void saveSobjectSet(List <Sobject> listToUpdate) {
Integer SFDC_CHUNK_LIMIT = 10;
// Developed this part due to System.TypeException: Cannot have more than 10 chunks in a single operation
Map<String, List<Sobject>> sortedMapPerObjectType = new Map<String, List<Sobject>>();
Map<String, Integer> numberOf200ChunkPerObject = new Map<String, Integer>();
for (Sobject obj : listToUpdate) {
String objTypeREAL = String.valueOf(obj.getSObjectType());
if (! numberOf200ChunkPerObject.containsKey(objTypeREAL)){
@mhamzas
mhamzas / add_contents.html
Created July 14, 2021 17:18
Backup of old lwc componentd
<!--
@description :
@author : ChangeMeIn@UserSettingsUnder.SFDoc
@group :
@last modified on : 06-24-2021
@last modified by : ChangeMeIn@UserSettingsUnder.SFDoc
Modifications Log
Ver Date Author Modification
1.0 06-10-2021 ChangeMeIn@UserSettingsUnder.SFDoc Initial Version
-->