• Daniel Blevins
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
When someone COMMENTS on a POST in a CASE where do I find this Comment? I am trying to create some kind of workflow or process that updates another field when a post is made and that I have accomplished, but I need it to happen when these COMMENTS are left on posts as well but I cannot find where they are located and how to fire off of them. I have been looking for it via SOQL and cannot find the home of these things, I can find the post as FeedItem easily but I cannot find the Comments under it and how I relate them back to their Parent and the Case itself.

As the attached picture shows I have looked in the FeedItem,  UserFeed, CaseComment, Case objects and cannot find this item in any of them. 

User-added image
So this formula needs to Put down if a customer is an A,B, or C customer ranking depending on if the Annual Support field (which is a currency) is between these ranges, but we have two different kinds of structure depending on product. So the first IF is the split there, our JustWare customers have a ranking, and everything else falls into the other catagory, so IF product = Justware  TRUE first section ranking, False second ranking.  Right now it hates the formula and I was wondering if im missing a golden oppetunity to make this into a simpler CASE statement.

IF(Product__c = 'JustWare',
  IF(Annual_Support__c >=100000, 'A',
    IF(AND(Annual_Support__c<100000, Annual_Support__c >=50000), 'B',
     IF(Annual_Support__c>50000, 'C',
         )
       )
     ),
  IF(Annual_Support__c>=200000, 'A',
     IF(AND( Annual_Support__c<200000, Annual_Support__c >=80000), 'B',
        IF(Annual_Support__c>80000, 'C'
    )
   )
  )
)

I need the following to work, and I have writte it up to the AND clause, but I am trying to add a second kind of profile and need it to pick it up as well so what I have working is 

                          List<Case> caseList = [SELECT Id, OwnerId
                                                      FROM Case
                                                      WHERE Id IN :caseIdList
                                                      AND Owner.Profile.Name = 'Customer Community User'];

But what I need to do is:

                          List<Case> caseList = [SELECT Id, OwnerId
                                                      FROM Case
                                                      WHERE Id IN :caseIdList
                                                      AND (Owner.Profile.Name = 'Customer Community User'
                                                      OR Owner.Profile.Name = 'Advanced Community User')];

but it keeps giving me errors on the syntax for this, how do i put the OR in there? Id IN :caseIdList has to apply to all, then EITHER other of the other two can be true and it should pull it to list.

I am using the following trigger which should look at the case being created, make it a default admin user for the time being (for permissions), look only for WEB based bases to change the user ( which i think isn't working right either) and then add everyone with a checkbox on their contact as a case team member. However I get an error but ONLY when adding a case from our community. What about those users would mess this up?

 

trigger CaseTeamAddition on Case (after insert) {
 
  if (Trigger.isAfter){
                If (Trigger.isInsert){
                                CaseTeamRole caseTeamRole = [SELECT Id 
                                                            FROM CaseTeamRole 
                                                            WHERE Name = 'Case Update Team'
                                                            LIMIT 1];
 
                                List<Id> accountIdList = new List<Id>();
                          List<Id> caseIdList = new List<Id>();
                                For (Case currentCase : Trigger.new){
                                     accountIdList.add(currentCase.AccountId);
                                    caseIdList.add(currentCase.Id);
                                }
                          
                          User dbUser = [SELECT Id
                                                    FROM User
                                                    WHERE Alias = 'dblevins'
                                                    LIMIT 1];
                          
                          List<Case> caseList = [SELECT Id, OwnerId
                                                      FROM Case
                                                      WHERE Id IN :caseIdList
                                                      AND Type = 'Web'];
                          
                                for (Case curCase : caseList){
                                    curCase.OwnerId = dbUser.Id;
                                }
                          
                          update caseList;
                                
                                List<Contact> contactList = [SELECT Id, AccountId
                                                             FROM Contact
                                                             WHERE AccountId IN : accountIdList
                                                             AND Get_Email_Updates__c = true];
                                
                                List<CaseTeamMember> caseMembersToInsert = new List<CaseTeamMember>();
                                For (Case currentCase : Trigger.new){
                                  For (Contact currentContact : contactList){
                                     If (currentContact.AccountId == currentCase.AccountId){
                                           CaseTeamMember newMember = new CaseTeamMember(ParentId = currentCase.Id,
                                                                             MemberId = currentContact.Id,
                                                                                         TeamRoleId = caseTeamRole.Id);
                                            caseMembersToInsert.add(newMember);
                                        }
                                   }
                                }

                                if (caseMembersToInsert.size() > 0){
                                  insert caseMembersToInsert;
                                
                                }
                                                               
              }
  }                               

I am using the following APEX trigger to add Contacts automatically to cases that want to be (theres a check box for it) but it is not adding case team members to case. What am I missing here?

trigger CaseTeamAddition on Case (after insert) {
 
if (Trigger.isAfter){
                If (Trigger.isInsert){
                                CaseTeamRole caseTeamRole = [SELECT Id 
FROM CaseTeamRole 
WHERE Name = 'Case Update Team'
LIMIT 1];
 
                                List<Id> accountIdList = new List<Id>();
                                
                                For (Case currentCase : Trigger.new){
                                                accountIdList.add(currentCase.AccountId);
                                }
                                
                                List<Contact> contactList = [SELECT Id, AccountId
                                                                                    FROM Contact
                                                                                    WHERE AccountId IN : accountIdList
                                                                                   AND Get_Email_Updates__c = true];
                                
                                List<CaseTeamMember> caseMembersToInsert = new List<CaseTeamMember>();
                                For (Case currentCase : Trigger.new){
                                               
                                                For (Contact currentContact : contactList){
                                                                If (currentContact.AccountId == currentCase.AccountId){
                                                                               
                                                                                CaseTeamMember newMember = new CaseTeamMember(ParentId = currentCase.Id,
                                                                                                                                                                                                MemberId = currentContact.Id,
                                                                                                                                                                                                TeamRoleId = caseTeamRole.Id);
                                                                                caseMembersToInsert.add(newMember);
                                                                }
                                                }
                                }
 
                                if (caseMembersToInsert.size() > 0){
                                                insert caseMembersToInsert;
                                }
                                                               
                                }
}                               
    }

I am getting this error and it fails the deployment of my code, what am I missing to get this working? 

Class NameMethod NameError MessageABSI_TEST_MassTaskControllermyUnitTestSystem.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Cannot create a portal user without contact: [ContactId] 
Stack Trace: Class.ABSI_TEST_MassTaskController.myUnitTest: line 68, column 1

It is failing on the following code:

trigger CaseTeamAddition on Case (after insert) {
 
if (Trigger.isAfter){
                If (Trigger.isInsert){
                                CaseTeamRole caseTeamRole = [SELECT Id 
FROM CaseTeamRole 
WHERE Name = 'Case Update Team'
LIMIT 1];
 
                                List<Id> accountIdList = new List<Id>();
                                
                                For (Case currentCase : Trigger.new){
                                                accountIdList.add(currentCase.AccountId);
                                }
                                
                                List<Contact> contactList = [SELECT Id
                                                                                    FROM Contact
                                                                                    WHERE AccountId IN : accountIdList
                                                                                   AND Get_Email_Updates__c = true];
                                
                                List<CaseTeamMember> caseMembersToInsert = new List<CaseTeamMember>();
                                For (Case currentCase : Trigger.new){
                                               
                                                For (Contact currentContact : contactList){
                                                                If (currentContact.AccountId == currentCase.AccountId){
                                                                               
                                                                                CaseTeamMember newMember = new CaseTeamMember(ParentId = currentCase.Id,
                                                                                                                                                                                                MemberId = currentContact.Id,
                                                                                                                                                                                                TeamRoleId = caseTeamRole.Id);
                                                                                caseMembersToInsert.add(newMember);
                                                                }
                                                }
                                }
 
                                if (caseMembersToInsert.size() > 0){
                                                insert caseMembersToInsert;
                                }
                                                               
                                }
}                               
    }
 

When someone COMMENTS on a POST in a CASE where do I find this Comment? I am trying to create some kind of workflow or process that updates another field when a post is made and that I have accomplished, but I need it to happen when these COMMENTS are left on posts as well but I cannot find where they are located and how to fire off of them. I have been looking for it via SOQL and cannot find the home of these things, I can find the post as FeedItem easily but I cannot find the Comments under it and how I relate them back to their Parent and the Case itself.

As the attached picture shows I have looked in the FeedItem,  UserFeed, CaseComment, Case objects and cannot find this item in any of them. 

User-added image
So this formula needs to Put down if a customer is an A,B, or C customer ranking depending on if the Annual Support field (which is a currency) is between these ranges, but we have two different kinds of structure depending on product. So the first IF is the split there, our JustWare customers have a ranking, and everything else falls into the other catagory, so IF product = Justware  TRUE first section ranking, False second ranking.  Right now it hates the formula and I was wondering if im missing a golden oppetunity to make this into a simpler CASE statement.

IF(Product__c = 'JustWare',
  IF(Annual_Support__c >=100000, 'A',
    IF(AND(Annual_Support__c<100000, Annual_Support__c >=50000), 'B',
     IF(Annual_Support__c>50000, 'C',
         )
       )
     ),
  IF(Annual_Support__c>=200000, 'A',
     IF(AND( Annual_Support__c<200000, Annual_Support__c >=80000), 'B',
        IF(Annual_Support__c>80000, 'C'
    )
   )
  )
)

I am using the following trigger which should look at the case being created, make it a default admin user for the time being (for permissions), look only for WEB based bases to change the user ( which i think isn't working right either) and then add everyone with a checkbox on their contact as a case team member. However I get an error but ONLY when adding a case from our community. What about those users would mess this up?

 

trigger CaseTeamAddition on Case (after insert) {
 
  if (Trigger.isAfter){
                If (Trigger.isInsert){
                                CaseTeamRole caseTeamRole = [SELECT Id 
                                                            FROM CaseTeamRole 
                                                            WHERE Name = 'Case Update Team'
                                                            LIMIT 1];
 
                                List<Id> accountIdList = new List<Id>();
                          List<Id> caseIdList = new List<Id>();
                                For (Case currentCase : Trigger.new){
                                     accountIdList.add(currentCase.AccountId);
                                    caseIdList.add(currentCase.Id);
                                }
                          
                          User dbUser = [SELECT Id
                                                    FROM User
                                                    WHERE Alias = 'dblevins'
                                                    LIMIT 1];
                          
                          List<Case> caseList = [SELECT Id, OwnerId
                                                      FROM Case
                                                      WHERE Id IN :caseIdList
                                                      AND Type = 'Web'];
                          
                                for (Case curCase : caseList){
                                    curCase.OwnerId = dbUser.Id;
                                }
                          
                          update caseList;
                                
                                List<Contact> contactList = [SELECT Id, AccountId
                                                             FROM Contact
                                                             WHERE AccountId IN : accountIdList
                                                             AND Get_Email_Updates__c = true];
                                
                                List<CaseTeamMember> caseMembersToInsert = new List<CaseTeamMember>();
                                For (Case currentCase : Trigger.new){
                                  For (Contact currentContact : contactList){
                                     If (currentContact.AccountId == currentCase.AccountId){
                                           CaseTeamMember newMember = new CaseTeamMember(ParentId = currentCase.Id,
                                                                             MemberId = currentContact.Id,
                                                                                         TeamRoleId = caseTeamRole.Id);
                                            caseMembersToInsert.add(newMember);
                                        }
                                   }
                                }

                                if (caseMembersToInsert.size() > 0){
                                  insert caseMembersToInsert;
                                
                                }
                                                               
              }
  }                               

I am using the following APEX trigger to add Contacts automatically to cases that want to be (theres a check box for it) but it is not adding case team members to case. What am I missing here?

trigger CaseTeamAddition on Case (after insert) {
 
if (Trigger.isAfter){
                If (Trigger.isInsert){
                                CaseTeamRole caseTeamRole = [SELECT Id 
FROM CaseTeamRole 
WHERE Name = 'Case Update Team'
LIMIT 1];
 
                                List<Id> accountIdList = new List<Id>();
                                
                                For (Case currentCase : Trigger.new){
                                                accountIdList.add(currentCase.AccountId);
                                }
                                
                                List<Contact> contactList = [SELECT Id, AccountId
                                                                                    FROM Contact
                                                                                    WHERE AccountId IN : accountIdList
                                                                                   AND Get_Email_Updates__c = true];
                                
                                List<CaseTeamMember> caseMembersToInsert = new List<CaseTeamMember>();
                                For (Case currentCase : Trigger.new){
                                               
                                                For (Contact currentContact : contactList){
                                                                If (currentContact.AccountId == currentCase.AccountId){
                                                                               
                                                                                CaseTeamMember newMember = new CaseTeamMember(ParentId = currentCase.Id,
                                                                                                                                                                                                MemberId = currentContact.Id,
                                                                                                                                                                                                TeamRoleId = caseTeamRole.Id);
                                                                                caseMembersToInsert.add(newMember);
                                                                }
                                                }
                                }
 
                                if (caseMembersToInsert.size() > 0){
                                                insert caseMembersToInsert;
                                }
                                                               
                                }
}                               
    }

I am getting this error and it fails the deployment of my code, what am I missing to get this working? 

Class NameMethod NameError MessageABSI_TEST_MassTaskControllermyUnitTestSystem.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Cannot create a portal user without contact: [ContactId] 
Stack Trace: Class.ABSI_TEST_MassTaskController.myUnitTest: line 68, column 1

It is failing on the following code:

trigger CaseTeamAddition on Case (after insert) {
 
if (Trigger.isAfter){
                If (Trigger.isInsert){
                                CaseTeamRole caseTeamRole = [SELECT Id 
FROM CaseTeamRole 
WHERE Name = 'Case Update Team'
LIMIT 1];
 
                                List<Id> accountIdList = new List<Id>();
                                
                                For (Case currentCase : Trigger.new){
                                                accountIdList.add(currentCase.AccountId);
                                }
                                
                                List<Contact> contactList = [SELECT Id
                                                                                    FROM Contact
                                                                                    WHERE AccountId IN : accountIdList
                                                                                   AND Get_Email_Updates__c = true];
                                
                                List<CaseTeamMember> caseMembersToInsert = new List<CaseTeamMember>();
                                For (Case currentCase : Trigger.new){
                                               
                                                For (Contact currentContact : contactList){
                                                                If (currentContact.AccountId == currentCase.AccountId){
                                                                               
                                                                                CaseTeamMember newMember = new CaseTeamMember(ParentId = currentCase.Id,
                                                                                                                                                                                                MemberId = currentContact.Id,
                                                                                                                                                                                                TeamRoleId = caseTeamRole.Id);
                                                                                caseMembersToInsert.add(newMember);
                                                                }
                                                }
                                }
 
                                if (caseMembersToInsert.size() > 0){
                                                insert caseMembersToInsert;
                                }
                                                               
                                }
}                               
    }