4 Antworten
Hi Ricky, Below code can help you.
trigger deleteContact on Contact(before delete) {
Id profileId = userinfo.getProfileId();
String profileName = [Select Id from Profile where Id =: profileId].Name;
//if you are using Status field as picklist then write con.Status__c == 'Active'.
//if you are using Status field as checkbox then write con.Status.
for (Contact con: trigger.old) {
if (profileName == 'Sales' && con.Status__c) {
if (Trigger.isBefore) {
if (Trigger.isDelete) {
con.adderror('You cannot delete the record');
}
}
}
}
}
Let me know if you have any confusion..
Kindly mark this as solved if the reply was helpful.Thanks,Murali