Skip to content

Instantly share code, notes, and snippets.

@sfdcale
sfdcale / AccSearch.cmp
Last active June 25, 2017 15:51
Lightning Assistive search explained in this article (http://www.jitendrazaa.com/blog/salesforce/lightning-component-for-wikipedia-search/) updated for account search
<aura:component controller="AccSearchController" implements="force:appHostable,flexipage:availableForAllPageTypes">
<aura:attribute name="accSearchText" type="String"/>
<aura:attribute name="resultLimit" type="Integer" default="4"/>
<div class="slds-card">
<div class="slds-card__header slds-grid">
<div class="slds-media slds-media--center slds-has-flexi-truncate">
<div class="slds-media__figure">
<lightning:icon iconName="custom:custom68"></lightning:icon>
</div>
@sfdcale
sfdcale / ExampleApp.app
Last active April 27, 2018 13:36
Dependent Picklists in Lightning component
<aura:application extends="force:slds">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
<aura:attribute name="dataArray" type="List"/>
<aura:attribute name="stateList" type="List"/>
<aura:attribute name="stateCityMap" type="Object"/>
@sfdcale
sfdcale / ReportsFinder.java
Last active January 23, 2018 18:06
Find Salesforce Reports using specific fields
package com.MyProject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.io.BufferedReader;
import java.io.File;
@sfdcale
sfdcale / RetrieveAllReports.cls
Last active January 23, 2018 18:13
Code to retrieve all reports in Salesforce
//First query all ReportFolders in the org.
Map<Id,Folder> folderMap = new Map<Id,Folder>([SELECT Id,
DeveloperName,
NameSpacePrefix
FROM Folder
WHERE
Type = 'Report']);
//Query all reports in the system.
List<Report> reportList = [SELECT FolderName,
@sfdcale
sfdcale / MainClass.java
Last active December 2, 2018 23:35
This script finds all the files in which specific fields are used.
package com.RollUpSummaryFieldFinder;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@sfdcale
sfdcale / gist:d4b4712f29fc0f1a88d30c8eb7134c9f
Created July 12, 2018 02:22
How to get all formula fields on a Object
Run the below query in Developer console with Toolin API checked.
SELECT QualifiedApiName,
IsCalculated
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName ='Opportunity'
AND IsCalculated = true
@sfdcale
sfdcale / RetrieveAllDashboardNames.cls
Created July 16, 2018 18:40
Salesforce script to retrieve all Dashboards and their folder names
//First query all DashboardDolder in the org.
Map<Id,Folder> folderMap = new Map<Id,Folder>([SELECT Id,
DeveloperName,
NameSpacePrefix
FROM Folder
WHERE
Type = 'Dashboard']);
//Query all Dashboards in the system.
List<Dashboard> dashboardList = [SELECT FolderId,
@sfdcale
sfdcale / How to show exception message in lightning without stacktrace?.md
Last active July 25, 2018 14:23
How to show exception message in lightning without stacktrace?

This is in reference to post https://salesforce.stackexchange.com/questions/226338/how-to-show-exception-message-in-lightning-without-stacktrace/226381#226381

Here I am attaching the zip file containing all the metadata that you can deploy to org and reproduce the problem.

  1. Download the zip file.
  2. Deploy the zip file to your developer edition org
  3. Find a account which has only one Opportunity.
  4. Update Account Id in OpportunityTrigger.trigger and update Opportunity Id in TestAppController.cls
  5. Edit Account page layout in lightning experience and add HelloWorld.cmp to the layout.
  6. Save the layout.
  7. Once layout is saved, go to the layout and click on delete button as I am doing in this video: https://vimeo.com/281628694
@sfdcale
sfdcale / ContactObject.cls
Last active July 29, 2018 15:27
DownCasting Failing In Custom APEX Classes
public class ContactObject extends SubscribeObject {
//Instance
public Contact record;
public Contact oldRecord;
public Contact originalRecord;
public ContactObject(SObject record, SObject oldRecord, Boolean editInPlace) {
// super needs to be the first thing called, if you use it
super(record, oldRecord, editInPlace);
@sfdcale
sfdcale / testLwc.html
Created May 1, 2019 02:56
change button on click
<template>
<button class={cssClass}>
<lightning-icon icon-name={iconName} onclick={handleToggleClick}>Non Profit</lightning-icon>
</button>
</template>