Last active
August 29, 2015 14:16
-
-
Save charltonAthletic/6ae5a6f8085e72b6e23b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This simple trigger changes the value of the standard Activity field 'Type' on task records to 'Email' if, before insert, the task is BLANK. | |
// This trigger could be improved upon by creating a method in a helper class to keep the trigger logicless. | |
trigger TaskWithBlankType of Task (before insert) { // 'before insert' is the trigger context variable | |
for (Task t : Trigger.new) { // for loop - for all tasks which match the trigger context variable... | |
if (t.Type == null) { // if branch nested in the for loop. If the type on the task is empty... | |
t.Type = 'Email'; // change the value of the Type to 'Email'. Remember: no DML operations required on 'before' trigger context variables | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment