Skip to main content
Dilip Kulkarni が「#Apex」で質問
Employee object is in lookup relation with account,When we will create Event Record with Condition (Event Status = Closed) and once we click on save ,it should create Employee record automatically.What will be the trigger for it?
18 件の回答
  1. 2017年6月22日 9:22
    HI Dilip,

    Trigger should be written on Event not account. Also you can get this done with process builder as well, If you prefer.

     

    trigger AutoCreateEmployee on Event (after insert)

    {

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

    for (Event newEmployee: Trigger.New) {

    if (newEmployee.Event_Status = Closed)

    {

    employees.add(new Employee__c (

    Name = '1',

    Employee__c = newPosition.Id,

    Role__c = 'Managerial'));

    }

    }

    insert employees ;

    }

    Please mark as best answer if the above helps ..!!!

     
0/9000