This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ApexClass | |
System.debug('Starting ApexClass analysis'); | |
Map<Decimal, Integer> apexClassMap = new Map<Decimal, Integer>(); | |
List<ApexClass> apexClassList = [ | |
SELECT Id, Name, ApiVersion | |
FROM ApexClass | |
WHERE NamespacePrefix = null | |
AND (NOT Name LIKE '%Test') | |
ORDER BY ApiVersion, Name | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(CronTrigger cronJob : [SELECT Id, CronExpression,CronJobDetailId, CronJobDetail.Name, CronJobDetail.JobType FROM CronTrigger]) { | |
System.abortJob(cronJob.Id); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c), Andrew Fawcett | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without modification, | |
* are permitted provided that the following conditions are met: | |
* | |
* - Redistributions of source code must retain the above copyright notice, | |
* this list of conditions and the following disclaimer. | |
* - Redistributions in binary form must reproduce the above copyright notice, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger AccountTrigger on Account(before insert, before update, before delete, after insert, after update, after delete, after undelete) { | |
new AccountTriggerHandler.execute(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the reports & dashboards | |
List<Report> reports = [SELECT Id, DeveloperName, FolderName FROM Report ORDER BY FolderName, DeveloperName]; | |
Set<String> folderNames = new Set<String>(); | |
for (Report report : reports) { | |
folderNames.add(report.FolderName); | |
} | |
List<Dashboard> dashboards = [SELECT Id, DeveloperName, FolderName FROM Dashboard ORDER BY FolderName, DeveloperName]; | |
for (Dashboard dashboard : dashboards) { | |
folderNames.add(dashboard.FolderName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess, json, os, platform, sys, getopt | |
import xml.dom.minidom | |
API_VERSION = '49.0' | |
NAMESPACE = { | |
'salesforce' : 'http://soap.sforce.com/2006/04/metadata', | |
'xsi' : 'http://www.w3.org/2001/XMLSchema-instance' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script converts any DLRS rules (stored in dlrs__LookupRollupSummary2__mdt) to Rollup__mdt records and deploys them to the current org | |
// Use the org defaults for all converted rules | |
static final RollupControl__mdt ROLLUP_CONTROL = [SELECT Id, DeveloperName FROM RollupControl__mdt WHERE DeveloperName = 'Org_Defaults']; | |
// Prepare the converted Rollup__mdt CMDT records for deployment | |
Metadata.DeployContainer deployment = new Metadata.DeployContainer(); | |
for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt.getAll().values()) { | |
String customMetadataTypePrefix = Schema.Rollup__mdt.SObjectType.getDescribe().getName().replace('__mdt', ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the email templates | |
Set<String> folderNames = new Set<String>(); | |
List<EmailTemplate> emailTemplates = [SELECT Id, DeveloperName, FolderName FROM EmailTemplate ORDER BY FolderName, DeveloperName]; | |
for (EmailTemplate emailTemplate : emailTemplates) { | |
folderNames.add(emailTemplate.FolderName); | |
} | |
// Get the folder dev names - this assumes the Folder.Name (display name) is unique in the org | |
Map<String, String> folderDisplayNameToDevName = new Map<String, String>(); | |
for (Folder folder : [SELECT Id, DeveloperName, Name FROM Folder WHERE Name IN :folderNames and Name != 'Unfiled Public Classic Email Templates']) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String objectName = ''; //example 'Case' | |
public String layoutName = ''; //example: 'Case Layout' | |
new LayoutDescriber().run(objectName, layoutName); | |
// In anonymous Apex, you can define & run a class. | |
// In this script, using a class ensures all describe methods work, regardless of field-level security (FLS) | |
public without sharing class LayoutDescriber { | |
public void run(String objectName, String layoutName) { | |
layoutName = objectName + '-' + layoutName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PackageSubscriberMetrics { | |
public class SubscriberOrgSummary { | |
public Id parentOrgId; | |
public String subscriberName; | |
public Boolean installedInParentOrg = false; | |
public Integer numberOfOrgs = 0; | |
public List<SubscriberOrgDetails> subscriberOrgDetails = new List<SubscriberOrgDetails>(); | |
} | |
public class SubscriberOrgDetails { |
OlderNewer