Skip to content

Instantly share code, notes, and snippets.

Marty Chang martyychang

View GitHub Profile
martyychang /
Created Jan 31, 2020
List all field labels and field names for an object
import csv
import os
import xml.etree.ElementTree as ET
FIELDS_SUBDIR = 'fields'
OBJECTS_DIR = 'force-app/main/default/objects'
namespaces = {
martyychang / batch-create-records.js
Created Jan 24, 2020
Expected input objects for Salesforce "batch create records" and "batch update records" actions in
View batch-create-records.js
// You can reference the input variables using input.NAME
exports.step = function(input) {
return, function(row) {
// Please note that the format of this object is different
// from the format for the "Batch update records" operation.
return [
"key": "Role__c",
"value": row.role
martyychang / SobjectQueryGenerator.cls
Last active Dec 6, 2019
Generate Salesforce SELECT * query, Postgres CREATE TABLE statement and database-conf.xml content for a given object.
View SobjectQueryGenerator.cls
public class SobjectQueryGenerator {
private List<Schema.DescribeFieldResult> fieldDescList;
private Schema.DescribeSObjectResult sobjectDesc;
public SobjectQueryGenerator(Schema.DescribeSObjectResult sobjectDesc, Boolean includeCalculated) {
this.sobjectDesc = sobjectDesc;
this.fieldDescList = new List<Schema.DescribeFieldResult>();
for (Schema.SObjectField eachField : this.sobjectDesc.fields.getMap().values()) {
Schema.DescribeFieldResult eachDfr = eachField.getDescribe();
martyychang / .bash_profile
Created Oct 29, 2018
Better Git integration with Terminal on Mac OS X
View .bash_profile
# Git shell
source /Applications/
source /Applications/
export PS1='\[\033[0;36m\]\u@\h\[\033[0;35m\]:\[\033[0;33m\]\w\[\033[0;37m\]$(__git_ps1)\[\033[0m\]\n\$ '
martyychang /
Last active Oct 8, 2018
Generate a list of all fields and data types for a given object and send the metadata in CSV format via email
// README: This is the only line you need to edit (generally speaking)
// This is the object for which I want to extract the field describes.
// Running this script will send the resulting field list to your user's email,
// with the fields as an attached CSV file.
Schema.DescribeSObjectResult objectDescribe = Schema.SObjectType.OpportunityLineItem;
* Wrapper class to return CSV rows
public class FieldCsvWriter {
martyychang /
Last active Dec 28, 2018
Trailblazer .bin
# Check to require a username to be [given as argument][1]
# [1]:
if [ -z "$1" ]; then
echo ERROR: Username argument required!
# [terminate and indicate error][3]
# [3]:
exit 1
martyychang / .gitignore
Created Jul 17, 2017
MavensMate project init
View .gitignore
# MavensMate
# Sublime Text
martyychang / CommunityTopicListItemController.cls
Created Apr 18, 2017
Server-side controller for Lightning component enabling partner users to follow and unfollow topics
View CommunityTopicListItemController.cls
public class CommunityTopicListItemController {
public static void subscribe(Id entityId) {
ConnectApi.Subscription subscription =
ConnectApi.ChatterUsers.follow(Network.getNetworkId(), 'me', entityId);
public static void unsubscribe(Id subscriptionId) {
martyychang /
Last active Dec 13, 2016
Suggested directory structure for a web API project, written in Python


Handlers, etc. Everything needed to translate a web request into data that can be passed into a regular Python function and vice versa.


Typically this would be imported into an app like this.

martyychang /
Created May 24, 2016
How to map task names to task services
public class AdvertiserListingTaskService {
public void executeWithConfig(TaskConfig config) {
AdvertiserListingTask task = getTask();
task.apply(config);; // Or something like executor.execute(task)
You can’t perform that action at this time.