trigger DeleteCheck on Task (before delete) {
Id profileid=Userinfo.getProfileId();
profile profilname=[select Name from Profile where id=:profileid];
for(Task accountDuplicate:Trigger.old){
if(profilname.Name!='System Administrator'){
accountDuplicate.addError('No Access for Deletion');
}
}
}
Just try to login with other user and create a task and try to delete the tas, then you can see the following error message 'No Access for Deletion' as per the trigger.
Why dont you remove the delete button on task layout for other profiles,and make it visible for only system admin profile.
the below will work
Thanks
D Naveen Rahul
but how i check it after login from user??
what you need to check ??
Just try to login with other user and create a task and try to delete the tas, then you can see the following error message 'No Access for Deletion' as per the trigger.