• FireStarter
  • NEWBIE
  • 0 Points
  • Member since 2014

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

Hello fellow developers!

I've looked at the developer boards and can't quite find what I'm looking for.
Basically, what I'm trying to achieve is to create an internal contact record for every User record that is created. **This contact should be associated to the Internal Accounts that essentially hold internal contact information.

I'm fairly new to writing code and have gotten as far as creating a new Contact record each time a User record is created, but I'm unable to see how a 'conditional account assignment' can be done to this.

trigger AutoCreateContactonUser on User (after insert){

if(Trigger.isInsert){
    List<Contact> ct = new List<Contact>();
    
    for(User u : trigger.new){
        Contact c = new Contact(LastName = u.lastname);

ct.add(c); 
        
    }
insert ct;
}


}

==============================================
To this, I would like to add a condition which would logically read as 'IF the User being created is from Australia (country / address info) THEN create a contact in the Internal APAC Account'

Appreciate any assistance,
Thanks