• Appy123
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,

I have created the following trigger on caseComment.

if(Trigger.isBefore && Trigger.isDelete)
{
cls_Case_Comment.CheckAssignedPermissionSet(trigger.old);
}
}

Below is the Helper Class:
Public with sharing class cls_Case_Comment {

Public Static Void CheckAssignedPermissionSet(List<CaseComment>newList)
{
/* This Method is used as Helper Method for trigger trg_Case_Comment 

Set<String>str_set= new Set<String>();
String profile_Name =[SELECT Name from Profile where Id=:UserInfo.getProfileId()].Name;   

List<PermissionSet>lst_PermissionSet = [SELECT Id, Name from PermissionSet where ID in ( SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId =:Userinfo.getUserId())];

for(PermissionSet ps:lst_PermissionSet){
str_set.add(ps.Name);
}

for(CaseComment cs:newList)
{
         if(profile_Name!='System Administrator'){
         if(!str_set.contains('Delete_cases'))
           {
                cs.addError(system.label.trg_cls_Case_Comment);
           }
         }

}

}

}

Everything is Working Correctly except on Deleting the CaseComment, I am getting a null value.

Error message is displaying correctly
User-added image
Hi,

I have created the following trigger on caseComment.

if(Trigger.isBefore && Trigger.isDelete)
{
cls_Case_Comment.CheckAssignedPermissionSet(trigger.old);
}
}

Below is the Helper Class:
Public with sharing class cls_Case_Comment {

Public Static Void CheckAssignedPermissionSet(List<CaseComment>newList)
{
/* This Method is used as Helper Method for trigger trg_Case_Comment 

Set<String>str_set= new Set<String>();
String profile_Name =[SELECT Name from Profile where Id=:UserInfo.getProfileId()].Name;   

List<PermissionSet>lst_PermissionSet = [SELECT Id, Name from PermissionSet where ID in ( SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId =:Userinfo.getUserId())];

for(PermissionSet ps:lst_PermissionSet){
str_set.add(ps.Name);
}

for(CaseComment cs:newList)
{
         if(profile_Name!='System Administrator'){
         if(!str_set.contains('Delete_cases'))
           {
                cs.addError(system.label.trg_cls_Case_Comment);
           }
         }

}

}

}

Everything is Working Correctly except on Deleting the CaseComment, I am getting a null value.

Error message is displaying correctly
User-added image