Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public String getResponse() {
  2. System.debug('I am in!');
  3.  
  4. if(validate()) {
  5. Visitor newVisitor = new Visitor();
  6. newVisitor.Name = 'John Smith';
  7. newVisitor.Identifier = 'john@somewhere.com';
  8. insert newVisitor;
  9. return '{"success":"true"}';
  10. }
  11.  
  12. return '{"success":"false"}';
  13. }
  14.  
  15. Visitor__c newVisitor = new Visitor__c ();
  16. newVisitor.Name = 'John Smith';
  17. newVisitor.Identifier__c = 'john@somewhere.com';
  18. insert newVisitor;
  19.  
  20. try
  21. {
  22. insert newVisitor;
  23. }
  24. catch( DmlException ex )
  25. {
  26. // fail gracefully
  27. }
  28.  
  29. try
  30. {
  31. Database.SaveResult[] MySaveResult = Database.Insert(newVisitors, false);
  32. }
  33. catch( DmlException ex )
  34. {
  35. // fail gracefully
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement