You need to sign in to do that
Don't have an account?
Mike Tol 1
Delete contact from table by id
Hi!
How can I delete definite contact from table by id?
Apex:
@AuraEnabled
public static void deleteContact(Id contactId) {
List<Contact> deleteContact =
[SELECT Id
FROM Contact
WHERE Id = :contactId
];
delete deleteContact;
}
Js:
handleDelete() {
console.log("launch");
deleteContact()
.then(result => {
console.log(result, 'end')
this.contacts = result;
})
.catch(error => {
console.log(error, "err")
this.error = error;
});
}
How can I delete definite contact from table by id?
Apex:
@AuraEnabled
public static void deleteContact(Id contactId) {
List<Contact> deleteContact =
[SELECT Id
FROM Contact
WHERE Id = :contactId
];
delete deleteContact;
}
Js:
handleDelete() {
console.log("launch");
deleteContact()
.then(result => {
console.log(result, 'end')
this.contacts = result;
})
.catch(error => {
console.log(error, "err")
this.error = error;
});
}
All Answers
Refer the below link have similar kind of solution.
https://salesforcescool.blogspot.com/2021/11/delete-multiple-records-in-datatable-in.html
If this helps, Please mark it as best answer.
Thanks!!
@AuraEnabled
public static void deleteContact(Id recordId) {
List<Contact> contacts =
[SELECT Id FROM Contact WHERE Id = :recordId];
delete contacts;
}
handleDelete() {
deleteContact({recordId: this.recordId})
.then(result => {
this.contacts = result;
})
.catch(error => {
this.error = error;
});
}