Skip to content

Instantly share code, notes, and snippets.

@cdeckert
Created December 15, 2015 20:33
Show Gist options
  • Save cdeckert/311b10e49d2ddb11d5ca to your computer and use it in GitHub Desktop.
Save cdeckert/311b10e49d2ddb11d5ca to your computer and use it in GitHub Desktop.
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();
newAntrag.Name = 'Galina';
//newAntrag.von__c = e.StartDateTime;
//newAntrag.bis__c = e.EndDateTime;
insert newAntrag;
e.WhatId = newAntrag.id;
}
else
{
Antrag__c newAntrag = new Antrag__c(id = newAntrag.WhatId);
newAntrag.Name = 'Galina';
//newAntrag.von__c = e.StartDateTime;
//newAntrag.bis__c = e.EndDateTime;
update newAntrag;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment