+ Start a Discussion
Mats ErikssonMats Eriksson 

Determining if a case comment trigger fires on a comment made by an SSP user



I have created a trigger on case comments that update a field on the parent case. It works very nicely. But when I want to select only cases that are created by SSP Users I have run into problems.


I tried getUserType() in the rem:ed line below (I also check for case status there) but it doesn't act differently so I assum both internal and external SSP users are of type 'Standard''


trigger IsNewCaseComment on CaseComment (after insert) {
Map<Id,CaseComment> cMap = new Map<Id,CaseComment>();
  for (CaseComment t: Trigger.new){
  List<Case> CasesToUpdate = new List<Case>();
  Set<Id> idSet = cMap.keySet();
  for(Case c:[select Id,CreatedById,Status,IsNewCaseComment__c from Case where Id in :idSet]) {
	//if (C.Status !='Waiting for Documentation' &&  UserInfo.getUserType()!='Standard'){
  update CasesToUpdate;


Any idea on how to proceed?


That's a good question.  In the API documentation for the User object, there is a description of the UserType field.  I assume these are the values returned by getUserType():



You could also retrieve the User record and test the value of the isPortalEnabled field.