Skip to main content
added 76 characters in body
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

I need to create a trigger that will prevent the deletion of a task by anyone other than the creator. I don't know about writing code so I'm hoping someone can help me out with this. It would be an assigned task on a custom object called Closings if that makes any difference. Help!?

trigger NoDeleteonAssignedTask on Task (before delete) {

String ProfileId = UserInfo.getProfileId();String UserID = Userinfo.getUserId(); List profiles=[select id from Profile where name='PB Administrator'];

if (1!=profiles.size()) { // unable to get the profiles - handle error } else {

for (Task a : Trigger.old)

IF(a.IsAssigned__c==True &&(UserID!=a.CreatedbyID && (profileId!=profiles[0].id ))) { Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.ERROR,'deletetaskerror'));

String ProfileId = UserInfo.getProfileId();String UserID = Userinfo.getUserId(); 
List<Profile> profiles=[select id from Profile where name='PB Administrator'];

if (1!=profiles.size())
{
   // unable to get the profiles - handle error
}
else
{

for (Task a : Trigger.old)      
            
IF(a.IsAssigned__c==True &&(UserID!=a.CreatedbyID && (profileId!=profiles[0].id )))
{
     Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.ERROR,'deletetaskerror'));
     
            }
        }
}

}

I need to create a trigger that will prevent the deletion of a task by anyone other than the creator. I don't know about writing code so I'm hoping someone can help me out with this. It would be an assigned task on a custom object called Closings if that makes any difference. Help!?

trigger NoDeleteonAssignedTask on Task (before delete) {

String ProfileId = UserInfo.getProfileId();String UserID = Userinfo.getUserId(); List profiles=[select id from Profile where name='PB Administrator'];

if (1!=profiles.size()) { // unable to get the profiles - handle error } else {

for (Task a : Trigger.old)

IF(a.IsAssigned__c==True &&(UserID!=a.CreatedbyID && (profileId!=profiles[0].id ))) { Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.ERROR,'deletetaskerror'));

        }
    }

}

I need to create a trigger that will prevent the deletion of a task by anyone other than the creator. I don't know about writing code so I'm hoping someone can help me out with this. It would be an assigned task on a custom object called Closings if that makes any difference. Help!?

trigger NoDeleteonAssignedTask on Task (before delete) {
String ProfileId = UserInfo.getProfileId();String UserID = Userinfo.getUserId(); 
List<Profile> profiles=[select id from Profile where name='PB Administrator'];

if (1!=profiles.size())
{
   // unable to get the profiles - handle error
}
else
{

for (Task a : Trigger.old)      
            
IF(a.IsAssigned__c==True &&(UserID!=a.CreatedbyID && (profileId!=profiles[0].id )))
{
     Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.ERROR,'deletetaskerror'));
     
            }
        }
}
added 589 characters in body; edited tags
Source Link
JenB
  • 11
  • 1

I need to create a trigger that will prevent the deletion of a task by anyone other than the creator. I don't know about writing code so I'm hoping someone can help me out with this. It would be an assigned task on a custom object called Closings if that makes any difference. Help!?

trigger NoDeleteonAssignedTask on Task (before delete) {

String ProfileId = UserInfo.getProfileId();String UserID = Userinfo.getUserId(); List profiles=[select id from Profile where name='PB Administrator'];

if (1!=profiles.size()) { // unable to get the profiles - handle error } else {

for (Task a : Trigger.old)

IF(a.IsAssigned__c==True &&(UserID!=a.CreatedbyID && (profileId!=profiles[0].id ))) { Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.ERROR,'deletetaskerror'));

        }
    }

}

I need to create a trigger that will prevent the deletion of a task by anyone other than the creator. I don't know about writing code so I'm hoping someone can help me out with this. It would be an assigned task on a custom object called Closings if that makes any difference. Help!?

I need to create a trigger that will prevent the deletion of a task by anyone other than the creator. I don't know about writing code so I'm hoping someone can help me out with this. It would be an assigned task on a custom object called Closings if that makes any difference. Help!?

trigger NoDeleteonAssignedTask on Task (before delete) {

String ProfileId = UserInfo.getProfileId();String UserID = Userinfo.getUserId(); List profiles=[select id from Profile where name='PB Administrator'];

if (1!=profiles.size()) { // unable to get the profiles - handle error } else {

for (Task a : Trigger.old)

IF(a.IsAssigned__c==True &&(UserID!=a.CreatedbyID && (profileId!=profiles[0].id ))) { Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.ERROR,'deletetaskerror'));

        }
    }

}

edited tags
Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431
Source Link
JenB
  • 11
  • 1
Loading