Skip to content

Instantly share code, notes, and snippets.

View cdeckert's full-sized avatar

Christian Deckert cdeckert

View GitHub Profile
// copy mailing street to contact
trigger on Account (before insert, before edit)
{
List<Account> accounts = [SELECT ID, MailingStreet FROM Account WHERE AccountId = trigger.new];
for(int i = 0; i < accounts.length(); i++)
{
Account a = accounts[i];
List<Contact> contacts = [SELECT ID, MalingStreet from Contact WHERE AccountId = a.Id];
for(Contact c : contacts)
@cdeckert
cdeckert / Salesforce-Authentication.js
Created June 14, 2017 12:58
Salesforce-Authentication.js
////oAuth related code
//hardcoded here for easily tweaking this. should move this to ScriptProperties or better parameterize them
//step 1. we can actually start directly here if that is necessary
var AUTHORIZE_URL = '/services/oauth2/authorize';
//step 2. after we get the callback, go get token
trigger onActivity on Event (before insert, before update)
{
List<Antrag__c> antraege = new List<Antrag__c>();
for(Event e : trigger.new)
{
if(e.Abwesenheitsart__c == 'Krankheit' || e.Abwesenheitsart__c == 'Urlaub')
{
if(e.WhatId == null)
{
Antrag__c newAntrag = new Antrag__c();
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
@cdeckert
cdeckert / treeviewHeidelbergApp.js
Created March 8, 2015 21:46
treeviewHeidelbergApp
'use strict';
/**
* @ngdoc function
* @name treeviewHeidelbergApp.controller:HeidelbergtreeviewCtrl
* @description
* # HeidelbergtreeviewCtrl
* Controller of the treeviewHeidelbergApp
*/
var slice = [].slice;
public void massUpdate() {
// first loop (don't forget to use Lists
for (List < Contact > contacts: [SELECT FirstName, LastName FROM Contact]) {
for (Contact c: contacts) { // 2nd for loop
if (c.FirstName == 'Barbara' &&
c.LastName == 'Gordon') {
c.LastName = 'Wayne';
}
}
update contacts; // update is part of the 1st for loop
<?xml version="1.0" encoding="UTF-8" ?>
<hotelliste>
<hotelkette name ="tempelhotels">
<hotel name="Devisen-Tempel">
<ausstattung typ="Casino" />
<ausstattung typ="Sonnenbank" />
<gaeste>
<gast>
<name>Gerald Futsch</name>
<zimmer>343</zimmer>
@cdeckert
cdeckert / RestDispatcher.cls
Created August 26, 2014 17:24
Rest Dispatcher
/**
* @description URL dispatcher
*/
@RestResource(urlMapping = '/*')
global class RestDispatcher
{
// dispatchables
static Map<RequestType, List<Dispatchable>> dispatchables;
// requestTypes
enum RequestType {HTTPGET, HTTPPOST, HTTPPUT, HTTPDELETE, HTTPPATCH}
{
"hd_geometry.heads": "-1",
"hd_geometry.sectors": "63",
"hd_geometry.start": 0,
"hd_geometry.cylinders": 2088,
"HDIO_GET_UNMASKINTR": 140518042901248,
"HDIO_GET_MULTCOUNT": 140518042901248,
"HDIO_GET_IDENTITY": "@�??VBaa570e48-83e1c9011.0VBOXHARDDISK��@���??���xxxx~"ht@h4@@��",
"HDIO_GET_KEEPSETTINGS": 140518042901248,
"HDIO_GET_32BIT": 140518042901249,
@cdeckert
cdeckert / gist:7083499
Last active December 26, 2015 03:09
Stop all scheduled jobs in Salesforce
List<CronTrigger> listCronTrigger = [SELECT Id, CronExpression, EndTime, NextFireTime, OwnerId,
PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey FROM CronTrigger
WHERE State != 'DELETED'];
System.debug('#### Number of jobs: '+listCronTrigger.size());
if (listCronTrigger.size() > 0)
{
for (CronTrigger aCronTrigger : listCronTrigger)
{
System.abortJob(aCronTrigger.Id);