You need to sign in to do that
Don't have an account?
Jason Wenig
Outlook Integration and Delete Trigger issue when associating with Opp or Acct
My org uses a Detete trigger to prevent the Salespeople from removing tasks assigned to them. Somehow the following delete trigger on the Task is being called during the association of an Email via Outlook to an Account or Opportunity. The trigger is not called when associated to a Contact. I'm not sure how to update the trigger to get around this issue.
trigger NoDeleteonTask on Task (before delete)
{
String ProfileId = UserInfo.getProfileId();
List<Profile> profiles=[select id from Profile where name='TJC Business Development User' or name='TJC Business Development User No Transfer'];
if (2!=profiles.size())
{
// unable to get the profiles - handle error
}
else
{
for (Task a : Trigger.old)
{
if ( (profileId==profiles[0].id) || (profileId==profiles[1].id) )
{
a.addError('Business Development profiles cannot delete tasks');
}
}
}
trigger NoDeleteonTask on Task (before delete)
{
String ProfileId = UserInfo.getProfileId();
List<Profile> profiles=[select id from Profile where name='TJC Business Development User' or name='TJC Business Development User No Transfer'];
if (2!=profiles.size())
{
// unable to get the profiles - handle error
}
else
{
for (Task a : Trigger.old)
{
if ( (profileId==profiles[0].id) || (profileId==profiles[1].id) )
{
a.addError('Business Development profiles cannot delete tasks');
}
}
}
We are having a similar issue trying to log an email to an Opportunity record using the Outlook Integration. When the email has an attachment the following error is returned:
---------------
The attached email could not be processed because the Apex class Messaging.EmailToSalesforceHandler failed.
System.UnexpectedException: Task cannot be deleted, please contact your system administrator.
We have an Trigger that prohibits any email/event/task/file from being deleted. The trigger prohibits a task/email/event/file from being deleted however using the integration we are trying to attach a file(s) to the task that is being created using the Integration.
Apex Class details:
are if they are specified in the DeletePermissions__c custom settings.
*/
public class EmailMessageTriggerHandler {
public static void onBeforeDelete(List<EmailMessage> eventList) {
try {
DeletePermissions__c permissions = [SELECT SetupOwnerId, Delete_Emails__c, Delete_Events__c, Delete_Files__c, Delete_Tasks__c FROM DeletePermissions__c LIMIT 1];
if(UserInfo.getProfileId() == permissions.SetupOwnerId && permissions.Delete_Emails__c == true){
//Objects may be deleted under this condition
}else{
for (EmailMessage e : eventList) {
e.addError('Email cannot be deleted, please contact your system administrator.');
}
}
} catch (Exception ex) {
System.debug('Custom Settings: "Delete Files, Tasks, and Events" must be set');
for (EmailMessage e : eventList) {
e.addError('Email cannot be deleted, please contact your system administrator.');
}
}
}
}
DG Paystub (https://www.dgpaystub.net/)