Skip to content

Instantly share code, notes, and snippets.

@sfdcale
sfdcale / printtestclassnames.js
Created October 29, 2019 18:49
This prints all test class names while keeping apex test execution opened.
var classnamescommaseperated = ''; document.querySelectorAll('div[class="x-grid3-cell-inner x-grid3-col-1"][unselectable="on"]').forEach((obj) => {classnamescommaseperated = classnamescommaseperated + ',' + obj.innerText;}); console.log(classnamescommaseperated);
@sfdcale
sfdcale / PrintTestClassNames.sh
Created November 1, 2019 04:33
This command prints all the test class names present in the org.
sfdx force:data:soql:query
--query="SELECT Id,Name,SymbolTable FROM ApexClass WHERE NamespacePrefix = ''"
--usetoolingapi
--targetusername=prod
--json
| jq '.result.records[] | select(.SymbolTable != null)
| select(.SymbolTable.methods[].annotations[].name == "IsTest")'
| jq '.Name' | uniq
@sfdcale
sfdcale / CreateCustomField.cls
Created November 6, 2019 20:10
This apex code is to create custom field.
String sessionId = UserInfo.getOrganizationId()+''+UserInfo.getSessionId().SubString(15);
List<String> objNames = new List<String>{'ConsumptionRate','ConsumptionSchedule','ProductConsumptionSchedule'};
for(String objectapiname: objNames){
String fieldapiname = 'External_Id';//replace with your field name
String fieldlabel = 'External Id';//replace with your field label
String fielddescription = 'External Id required for migration fro records between environments. Don\'t touch this field.';
String inlineHelpText = 'External Id required for migration fro records between environments. Don\'t touch this field.';
@sfdcale
sfdcale / ResolveGitMegeConflicts.sh
Created November 13, 2019 21:29
Script to resolve conflicts during git merge using their strategy
#!/bin/bash
rm -f "out.txt"
git diff --name-only --diff-filter=U > out.txt
while IFS= read -r fileName
do
echo "$fileName"
git checkout --theirs "$fileName"
done < out.txt
@sfdcale
sfdcale / listFileNamesFromGitStashes.sh
Created November 21, 2019 05:44
Lists file names from git stash
#!/bin/bash
for i in {0..13}
do
echo "Stash number: $i"
git stash show -p stash@{$i} --name-only | cat
done
@sfdcale
sfdcale / Salesforce_Partner.wsdl
Last active December 6, 2019 18:17
Salesforce partner wsdl
<?xml version="1.0" encoding="UTF-8"?>
<!--
Salesforce.com Partner Web Services API Version 47.0
Generated on 2019-12-06 18:17:28 +0000.
Copyright 1999-2019 salesforce.com, inc.
All Rights Reserved
-->
<definitions targetNamespace="urn:partner.soap.sforce.com"
@sfdcale
sfdcale / GenerateER.txt
Created December 11, 2019 04:17
How to generate Salesforce ER diagram
java -cp schemaSpy_5.0.0.jar:force-metadata-jdbc-driver-2.3.jar net.sourceforge.schemaspy.Main -t force -u Myusername -p Mypassword -font Arial -fontsize 8 -hq -norows -o doc -db Myorgname -desc "Extracted from Myorgname" -connprops url\\=https://test.salesforce.com/services/Soap/u/23.0
@sfdcale
sfdcale / vf.page
Last active December 15, 2019 03:08
This is my approach of how to disable commandButton until first click is processed and re-enable after first click results are returned from controller to page.
<apex:page>
<script>
var defaultEventListenerForSubmitBtn;
</script>
<apex:outputPanel id="op-panel">
</apex:outputPanel>
<apex:commandButton value="Submit"
action="{!controllerActionMethod}"
rerender="op-panel"
onclick="this.value='Processing..';defaultEventListenerForSubmitBtn = this.onclick;this.onclick=function(){this.value='Processing..';return false;}"
@sfdcale
sfdcale / DeleteMergedBranches.sh
Last active December 27, 2019 02:46
Script to delete merged branches
#!/bin/bash
git remote prune origin
rm -f branchesToDelete.txt
git branch -r --merged TEST > branchesToDelete.txt
sed -i '.bak' 's/^[ \t]*origin\///g' branchesToDelete.txt
sed -i '.bak' '/master/d; /QA_branch/d; /Production/d; /OSA_Invoices_Payment/d; /TEST/d; /Invoice_One_Time_Payment/d;' ./branchesToDelete.txt
input="branchesToDelete.txt"
while IFS= read -r branchName
do
@sfdcale
sfdcale / PrintFormulaFields.sh
Created January 18, 2020 04:32
Print formulas for a given Salesfroce object
sfdx force:schema:sobject:describe --sobjecttype=Foo_A__c --targetusername=dev --json | jq '.result.fields[]' | jq 'select(.calculatedFormula != null)' | jq '.name'