@dlog Restful JSON VF Page


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1.  
  2. public with sharing class AccountTriggerHandler {
  3. private boolean m_isExecuting = false;
  4. private integer BatchSize = 0;
  5.  
  6. public AccountTriggerHandler(boolean isExecuting, integer size){
  7. m_isExecuting = isExecuting;
  8. BatchSize = size;
  9. }
  10.  
  11. public void OnBeforeInsert(Account[] newAccounts){
  12. //Example usage
  13. for(Account newAccount : newAccounts){
  14. if(newAccount.AnnualRevenue == null){
  15. newAccount.AnnualRevenue.addError('Missing annual revenue');
  16. }
  17. }
  18. }
  19.  
  20. public void OnAfterInsert(Account[] newAccounts){
  21.  
  22. }
  23.  
  24. @future public static void OnAfterInsertAsync(Set<ID> newAccountIDs){
  25. //Example usage
  26. List<Account> newAccounts = [select Id, Name from Account where Id IN :newAccountIDs];
  27. }
  28.  
  29. public void OnBeforeUpdate(Account[] oldAccounts, Account[] updatedAccounts, Map<ID, Account> accountMap){
  30. //Example Map usage
  31. Map<ID, Contact> contacts = new Map<ID, Contact>( [select Id, FirstName, LastName, Email from Contact where AccountId IN :accountMap.keySet()] );
  32. }
  33.  
  34. public void OnAfterUpdate(Account[] oldAccounts, Account[] updatedAccounts, Map<ID, Account> accountMap){
  35.  
  36. }
  37.  
  38. @future public static void OnAfterUpdateAsync(Set<ID> updatedAccountIDs){
  39. List<Account> updatedAccounts = [select Id, Name from Account where Id IN :updatedAccountIDs];
  40. }
  41.  
  42. public void OnBeforeDelete(Account[] accountsToDelete, Map<ID, Account> accountMap){
  43.  
  44. }
  45.  
  46. public void OnAfterDelete(Account[] deletedAccounts, Map<ID, Account> accountMap){
  47.  
  48. }
  49.  
  50. @future public static void OnAfterDeleteAsync(Set<ID> deletedAccountIDs){
  51.  
  52. }
  53.  
  54. public void OnUndelete(Account[] restoredAccounts){
  55.  
  56. }
  57.  
  58. public boolean IsTriggerContext{
  59. get{ return m_isExecuting;}
  60. }
  61.  
  62. public boolean IsVisualforcePageContext{
  63. get{ return !IsTriggerContext;}
  64. }
  65.  
  66. public boolean IsWebServiceContext{
  67. get{ return !IsTriggerContext;}
  68. }
  69.  
  70. public boolean IsExecuteAnonymousContext{
  71. get{ return !IsTriggerContext;}
  72. }
  73. }
  74.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.