You need to sign in to do that
Don't have an account?

after delete trigger on task throwing validation error
Hi,
i have created a trigger on task so that task records cannot be deleted for a particular profile/record type:
trigger taskDelete on Task (before delete)
{
system.debug('inside taskdelete');
Id taskId;
ID shipperRecordType = [SELECT Id FROM RecordType WHERE Name = 'Interaction'].Id;
for(task a:Trigger.old)
{
if(shipperRecordType == a.recordTypeId)
{
system.debug('a.recordTypeId' + a.recordTypeId);
system.debug('shipperRecordType'+ shipperRecordType);
a.addErro.('you cannot delete this task');
}
}
the trigger is working properly but the error message is coming like this on the next page:
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "you cannot delete this task".
Is there any workaround for this???
Thanks
i have created a trigger on task so that task records cannot be deleted for a particular profile/record type:
trigger taskDelete on Task (before delete)
{
system.debug('inside taskdelete');
Id taskId;
ID shipperRecordType = [SELECT Id FROM RecordType WHERE Name = 'Interaction'].Id;
for(task a:Trigger.old)
{
if(shipperRecordType == a.recordTypeId)
{
system.debug('a.recordTypeId' + a.recordTypeId);
system.debug('shipperRecordType'+ shipperRecordType);
a.addErro.('you cannot delete this task');
}
}
the trigger is working properly but the error message is coming like this on the next page:
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "you cannot delete this task".
Is there any workaround for this???
Thanks
is there any example which can be helpful??
which is adding an error to the object. When the system tries to save this object it will have a validation error because you have added the error. Because you have defined a custom error it returns as a custom validation issue.