Skip to content

Instantly share code, notes, and snippets.

View mtetlow's full-sized avatar

Mike "Mikename" Tetlow mtetlow

View GitHub Profile
global class dailySummary implements Schedulable
{
global void execute(SchedulableContext ctx)
{
execFn();
}
public void execFn(){
//Do stuff
/*Usage*/
@RemoteAction
global static void archivePersonalTasksInLastColumn(){
trTaskboardController.setStaticVarsForRemoteActions();
//String lastListName=trController.getLastListName();
List<Project_Task__c> tasksToArchive = [SELECT Archived__c FROM Project_Task__c WHERE List__c = :lastListName AND Project__c = null AND OwnerId=:UserInfo.getUserId()];
for(Project_Task__c task : tasksToArchive){
task.Archived__c = true;
}
//update tasksToArchive;
var wat = {
'ar_SA': 'dd/mm/yy',
'bg_BG': 'dd.m.yyyy',
'ca_ES': 'dd/mm/yyyy',
'zh_TW': 'yyyy/m/d',
'cs_CZ': 'd.m.yyyy',
'da_DK': 'dd-mm-yyyy',
'de_DE': 'dd.mm.yyyy',
'el_GR': 'd/m/yyyy',
'en_US': 'm/d/yyyy',
@mtetlow
mtetlow / gist:e3efb643b9e7161da167
Created September 20, 2014 22:43
Salesforce fake locales to real locale date formats
var formats = {
'af_ZA': 'yyyy/mm/dd',
'am_ET': 'd/m/yyyy',
'ar': 'dd/mm/yy',
'ar_AE': 'dd/mm/yyyy',
'ar_BH': 'dd/mm/yyyy',
'ar_DZ': 'dd-mm-yyyy',
'ar_EG': 'dd/mm/yyyy',
'ar_IQ': 'dd/mm/yyyy',
'ar_JO': 'dd/mm/yyyy',
@mtetlow
mtetlow / gist:2b0bbd1ed7e373b7d5f7
Created September 21, 2014 15:04
locale fun explanation
Had to manually map, most are easy, sh -> sr made me look up the label though... after I saw the label I knew I should have recognized it from the country codes:
iw
iw_IL
in
in_ID
sh_ME
no
no_NO
sh
sh_BA
if (!showWarning(this)) return false;bannerText=null;;A4J.AJAX.Submit('j_id0:j_id12',event,{'similarityGroupingId':'j_id0:j_id12:objectTable:213:j_id25','parameters':{'j_id0:j_id12:objectTable:213:j_id25':'j_id0:j_id12:objectTable:213:j_id25'} } )
<script>
document.addEventListener('DOMContentLoaded', pageFullyLoaded, false);
function pageFullyLoaded(){
var body = document.body,
html = document.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
alert(height);
Sfdc.canvas.publisher.resize( {height : height+'px'});
}
</script>
@mtetlow
mtetlow / gist:3cc4551173a263022d16
Created December 5, 2014 14:50
example of field describes to get a field name
Schema.DescribeSObjectResult d = Schema.getGlobalDescribe().get('Task').getDescribe();
Map<String,sObjectField> fields = d.fields.getMap();
for (String f : fields.keyset() ) {
Schema.DescribeFieldResult dfr = fields.get(f).getDescribe();
//system.debug(JSON.serialize(dfr));
system.debug(dfr.Name);
}
@mtetlow
mtetlow / gist:f33788b9de2e7c54cb01
Created December 22, 2014 15:55
Canvas Resize junk
<!-- include this fella -->
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
<script>
//Call whenever you do something that results in a frame resize, and probably on load
function resizeIframe(){
var containerHeight = document.getElementById('checklist-container').clientHeight;
Sfdc.canvas.publisher.resize( {height : containerHeight+'px'});
}
</script>
@RemoteAction
global static boardInfoWrapper toggleFollowTask(string taskId){
//Find if there is a current record
//Need to use without sharing
List<EntitySubscription> existingList = trControllerWithoutSharing.queryWithoutSharing('Select e.SubscriberId, e.ParentId From EntitySubscription e WHERE e.SubscriberId=\''+String.escapeSingleQuotes(UserInfo.getUserId())+'\' AND e.ParentId=\''+String.escapeSingleQuotes(taskId)+'\' LIMIT 1000');
//If no, insert a new one
if(existingList.size()==0){
EntitySubscription follow = new EntitySubscription (parentId = taskId,subscriberid = UserInfo.getUserId());
Map<String, Schema.SObjectField> fields = Schema.SObjectType.EntitySubscription.fields.getMap();
if(fields.get('NetworkId')!=null){