I have a custom object called Employee__c. Once I create a new User in Salesforce, a new and corresponding Employee__c record has to be automatically created in the system using the information from the User record.

How can I create a new Employe__c record out of a new User record?


This is pretty straight forward, but what the others said.. Process builder or trigger. I did this in the after context so you can link your Employee__c.User to it..

trigger User on User (after insert)
    List<User> userList = new List<User>();

    for(User u : Trigger.new)

    List<Employee__c> employeeList = new List<Employee__c>();

    for(User user : userList)
        Employee__c emp = new Employee__c();
        emp.User__c = user.ID;

    insert employeeList;

You can use Process builder or a trigger to create the Employee records.

  • How is your answer different than Derek's? – Raul Jul 10 '17 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.