You need to sign in to do that
Don't have an account?
Harikrishna Mandadapu
trigger NoDeleteonIsAssignedTask on Task (before delete)
{
String ProfileId = UserInfo.getProfileId();
set<Id> setwhatId=new set<Id>();
list<Task> lsttask=trigger.old;
for(Task ta:trigger.old){
setwhatId.add(ta.whatID);
}
list<employees__c> lst=[Select id from employees__c where id in :setwhatId];
for (Task a : Trigger.old) {
if( lst.size()>0 )
a.addError('You can\'t delete this record!'+a.id);
}
}
not able to show only validation message through trigger, here is my code
trigger NoDeleteonIsAssignedTask on Task (before delete)
{
String ProfileId = UserInfo.getProfileId();
set<Id> setwhatId=new set<Id>();
list<Task> lsttask=trigger.old;
for(Task ta:trigger.old){
setwhatId.add(ta.whatID);
}
list<employees__c> lst=[Select id from employees__c where id in :setwhatId];
for (Task a : Trigger.old) {
if( lst.size()>0 )
a.addError('You can\'t delete this record!'+a.id);
}
}
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Deletion of task is not allowed".
Click here to return to the previous page.
this is the validation message I am getting
You can check any validation rules on task object with message "Deletion of task is not allowed".
If you can not find any validation rule with this message, then this message is coming from a trigger from a package installed in your org.
Please mark as best answer if it solves your issue. Thanks