Created
March 28, 2014 13:01
-
-
Save pcon/9832142 to your computer and use it in GitHub Desktop.
How to make a trigger not run based on a static variable
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 would actually be your CaseTrigger.trigger but the hilighting wouldn't work then | |
List<ChatterPost> postsToInsert = new List<ChatterPost>(); | |
for (Case c: trigger.new) { | |
if (c.Status == 'collab') { | |
postsToInsert.add(new ChatterPost(...)); | |
} | |
if (!postsToInsert.isEmpty()) { | |
GenericUtils.UPDATE_CASE_VIA_CHATTER_POST = false; | |
insert postsToInsert; | |
for (ChatterPost post: postsToInsert) { | |
//Logic to copy chatterPost.Id to Case | |
} | |
} |
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
if (!GenericUtils.UPDATE_CASE_VIA_CHATTER_POST) { | |
return; | |
} | |
//Trigger logic |
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
public static Boolean UPDATE_CASE_VIA_CHATTER_POST = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment