Skip to content

Instantly share code, notes, and snippets.

@mattandneil
mattandneil / CustomMetadataClient.java
Last active February 5, 2020 16:09
Custom Metadata webservice client
public class CustomMetadataClient {
static public Database.UpsertResult upsertMetadata(SObjectType objectType, Map<SObjectField,Object> record) {
return upsertMetadata(objectType, new List<Map<SObjectField,Object>>{record})[0];
}
static public List<Database.UpsertResult> upsertMetadata(SObjectType type, List<Map<SObjectField,Object>> metadatas) {
if (Test.isRunningTest()) Test.setMock(WebServiceMock.class, new UpsertMetadataMock());
@mattandneil
mattandneil / build.xml
Last active November 14, 2022 18:18
Salesforce Organization Destroy - Ant Script
<macrodef name="destroy" description="Destroys all metadata in an organization - Revision 23">
<attribute name="username" />
<attribute name="password" />
<attribute name="serverurl" default="https://login.salesforce.com" />
<attribute name="tempDir" default="temp/destroy" description="Directory to write metadata." />
<attribute name="apiVersion" default="43.0" />
<sequential>
@mattandneil
mattandneil / build.xml
Last active July 21, 2019 23:58
Salesforce Execute Anonymous - Ant Script
<macrodef name="execanon" description="Executes apex code in an organization - Revision 7">
<text name="apexcode" />
<attribute name="username" />
<attribute name="password" />
<attribute name="serverurl" default="https://login.salesforce.com" />
<attribute name="apiVersion" default="44.0" />
<sequential>
@mattandneil
mattandneil / build.xml
Last active November 24, 2020 22:37
Salesforce Org Snapshot - Ant Script
<macrodef name="snapshot" description="Snapshots all metadata in an organization - Revision 22">
<attribute name="username" />
<attribute name="password" />
<attribute name="serverurl" default="https://login.salesforce.com" />
<attribute name="outPath" default="temp/snapshot" description="Directory to write snapshot." />
<sequential>
<!-- prompt user to confirm -->