Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @AuraEnabled(cacheable=true)
- public static String deleteContacts(List<String> contactIds) {
- List<Contact> returnList = new List<Contact> ();
- String query = ' SELECT Id,Name, LastName,Department,MobilePhone, Email FROM Contact WHERE id IN : contactIds ';
- for (Contact thisContact: Database.Query(query)) {
- returnList.add(thisContact);
- }
- try {
- delete returnList;
- return'deleted successfully';
- }
- catch(Exception ex){
- return 'Problem occoured';
- }
- }
- JS Method
- deleteSelected(){
- deleteContacts({
- contactIds :this.selectedIds
- })
- .then(result => {
- this.dispatchEvent(
- new ShowToastEvent({
- title: 'Success',
- message: result,
- variant: 'success',
- }),
- );
- return refreshApex(this.getContactList, { searchKeyWord: '$searchKeyWord' });
- })
- .catch(error => {
- this.error = error;
- });
Add Comment
Please, Sign In to add comment