Guest User

Untitled

a guest
Jan 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. @AuraEnabled(cacheable=true)
  2. public static String deleteContacts(List<String> contactIds) {
  3. List<Contact> returnList = new List<Contact> ();
  4. String query = ' SELECT Id,Name, LastName,Department,MobilePhone, Email FROM Contact WHERE id IN : contactIds ';
  5. for (Contact thisContact: Database.Query(query)) {
  6. returnList.add(thisContact);
  7. }
  8. try {
  9. delete returnList;
  10. return'deleted successfully';
  11. }
  12. catch(Exception ex){
  13. return 'Problem occoured';
  14. }
  15.  
  16. }
  17.  
  18. JS Method
  19. deleteSelected(){
  20. deleteContacts({
  21. contactIds :this.selectedIds
  22. })
  23. .then(result => {
  24. this.dispatchEvent(
  25. new ShowToastEvent({
  26. title: 'Success',
  27. message: result,
  28. variant: 'success',
  29. }),
  30. );
  31. return refreshApex(this.getContactList, { searchKeyWord: '$searchKeyWord' });
  32. })
  33. .catch(error => {
  34. this.error = error;
  35. });
Add Comment
Please, Sign In to add comment