You need to sign in to do that
Don't have an account?
Hermann Ouré
Stop Clients for commenting on Closed Cases in Community
Hello,
I am trying to stop clients from commenting on Closed Cases in client portal.
I am using a trigger on CaseComment. But the trigger does not work as clients can still comments on closed case.
Alternatively if someone has another suggestion that would stop clients from commenting on Closed Cases.
Please suggest alternatives.
Thanks
trigger ClosedCaseComment on CaseComment (before insert) { Set<Id> parentCase=new Set<Id>(); Map<Id,Case> mapCase=new Map<Id,Case>(); for (CaseComment t: Trigger.new) { parentCase.add(t.ParentId); } List<Case> lstCase=[Select Id,Status from case where Id in :parentCase ]; for(case c: lstCase){ mapCase.put(c.Id,c); } for (CaseComment t: Trigger.new){ if(mapCase.containskey(t.ParentId)) { if(mapCase.get(t.ParentId).Status=='Closed' && System.Userinfo.getUserType() == 'Standard'){ t.addError('You cannot add comments to closed cases.'); } } } }
Greetings!
We have an existing idea created for the same requirement with the workaround given which is to use the workflow.So,can you please check the below idea for more information:
https://trailblazer.salesforce.com/ideaView?id=087300000006trZ
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
I think the user type check that you have in your trigger is returning some other value than the Standard, that's why the trigger is not stopping the users from adding comments. Please check the possible return type values of this method as mentioned below and change the check as per the return value in your case:
- Standard: user license. This user type also includes Salesforce Platform and Salesforce Platform One user licenses. Label is Standard.
- PowerPartner: PRM user whose access is limited because he or she is a partner and typically accesses the application through a partner portal. Label is Partner.
- CSPLitePortal: user whose access is limited because he or she is an organization's customer and accesses the application through aCustomer Portal. Label is High Volume Portal.
- CustomerSuccess: user whose access is limited because he or she is an organization's customer and accesses the application through a Customer Portal. Label is Customer Portal User.
- PowerCustomerSuccess: user whose access is limited because he or she is an organization's customer and accesses the application through a Customer Portal. Label is Customer Portal Manager. Users with this license type can view and edit data they directly own or data owned by or shared with users below them in the Customer Portal role hierarchy.
- CsnOnly: user whose access to the application is limited to Chatter. This user type includes Chatter Free and Chatter moderator users. Label is Chatter Free.
Bold ones are the expected return values from method. Let me know if you need more help on this.Thanks,
Abhishek Bansal.
I have updated to the this
if(mapCase.get(t.ParentId).Status=='Closed' && System.Userinfo.getUserType() != 'Standard')
But still nothing happens with the trigger