Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import xmltodict
import glob
def getProfiles():
profiles = glob.glob('profiles/*.profile')
rows = getCSVShell(profiles[0])
for profile in profiles:
addColumns(profile, rows)
// must be in edit page of particular profile
// e.g., https://cs15.salesforce.com/00ee0000000Lw5d/e?s=ObjectsAndTabs&o=Account
// will add read to every field.
// doesnt change edit permissions
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
function main(){
List<Case> c = [SELECT Id, isDeleted FROM Case WHERE Id = '500C000000VlnSsIAJ'];
system.debug(c.size()); //1
//Formula field
c = [SELECT Id, Created_During_Business_Hours__c FROM Case WHERE Id = '500C000000VlnSsIAJ'];
system.debug(c.size()); //0
//Created_During_Business_Hours__c uses this field in formula
c = [SELECT Id, Actual_Case_Start_Time__c FROM Case WHERE Id = '500C000000VlnSsIAJ'];
system.debug(c.size()); //0
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
function main(){
var formulaFieldCells = $("td:contains('Formula (')");
var fieldList = [];
formulaFieldCells.each(function(){
formulaField = $($(this).prev()[0]).html();
import xmltodict
OBJECT_NAME = 'Case_Backup.object'
PICKLIST_FIELD = 'Team__c'
def parseRecordTypes():
for recordType in getRecordTypes():
parseRecordType(recordType)
def parseRecordType(recordType):
@mickle00
mickle00 / Metadata.java
Last active August 29, 2015 14:03
ApexMetadata API Samples
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.Layout layout = (MetadataService.Layout) service.readMetadata('Layout', new String[] { 'Account-Account Layout' }).getRecords()[0];
system.debug(JSON.serializePretty(layout.layoutSections[0].layoutColumns[0].layoutItems[0].field));
List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();
MetadataService.ListMetadataQuery queryListView = new MetadataService.ListMetadataQuery();
queryListView.type_x = 'ListView';
@mickle00
mickle00 / data_category_creator.js
Created July 30, 2014 22:33
May need to truncate length of strings, XML encode ampersands, and fit into the rest of the XML
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
var outputString = '';
function getAPISafeLabel(name){
name = name.replace(/\ /g,'_');
name = name.replace(/\//g,'_');
name = name.replace(/\,/g,'_');
string GROUP_NAME = 'LodgeOps Knowledge';
CollaborationGroup myGroup = [SELECT Id, Name FROM CollaborationGroup WHERE Name = :GROUP_NAME];
system.debug(myGroup);
List<User> pactUsers = [SELECT Id FROM User WHERE Profile.Name = 'Lodging Operations - PAC' AND isActive = true];
List<CollaborationGroupMember> groupMembers = new List<CollaborationGroupMember>();
for (User u : pactUsers){
groupMembers.add(
new CollaborationGroupMember(memberId = u.Id, CollaborationGroupId = myGroup.Id)
@mickle00
mickle00 / FlexQueueExample.cls
Created September 23, 2014 20:24
Showing that the Apex Flex Queue does not appear to work in the context of Unit Tests.
global class FlexQueueExample implements Database.Batchable<sObject>{
global Iterable<sObject> start(Database.BatchableContext BC) {
return new List<sObject> {};
}
global void execute(Database.BatchableContext BC, List<sObject> scope){}
global void finish(Database.BatchableContext BC){}
// Works in Execute Anonymous for Count <= 100
// This adds item to Batch Queue (limit 5, until FlexQueue)
// platform handles chunking up into batches of 200 records
// thus, getting new context of limits every batch
// Seems to be a Salesforce bug around FlexQueue in tests:
// See: https://gist.github.com/mickle00/70179703e885292793a0
// Also: https://twitter.com/mickle00/status/514511124125851648
Database.executeBatch(new VIPCSATSummaryUpdates());