• Sarah Choe
  • NEWBIE
  • 10 Points
  • Member since 2017

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

I am looking for a way to auto(pre) populate a Contact name as the curent user name when he/she create a new case.
This can be internal user creating a case and community user creating a case.
below is my take but when i test with clicking 'new' case, I still see 'Contact Name' blank and need to be searched. 

can anyone please help...?

trigger CaseContactName on Case (before insert) {

   // List <Case> caseContactName = new List <Case>();
    for (Case c : trigger.new){
    if(c.ContactId == null){
      c.ContactId = UserInfo.getUserId(); 
    }
    }
}
Hi all,

I am looking for a way to auto(pre) populate a Contact name as the curent user name when he/she create a new case.
This can be internal user creating a case and community user creating a case.
below is my take but when i test with clicking 'new' case, I still see 'Contact Name' blank and need to be searched. 

can anyone please help...?

trigger CaseContactName on Case (before insert) {

   // List <Case> caseContactName = new List <Case>();
    for (Case c : trigger.new){
    if(c.ContactId == null){
      c.ContactId = UserInfo.getUserId(); 
    }
    }
}