function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shriya BhalchandranShriya Bhalchandran 

Test 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 test record automatically.What will be the trigger for it?

Test 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 test record automatically.What will be the trigger for it?
VamsiVamsi
Hi Shriya,

You can get this bone using a process builder. Please give it a try instead of trigger.
Reference 
https://help.salesforce.com/articleView?id=process_overview.htm&type=0

Please mark as best answer if the above helps ...!!!
Shriya BhalchandranShriya Bhalchandran
hi, i created through process builder but unfortunately its nt possible.
 
VamsiVamsi
Hi,

Please try out the below. Please make sure to insert correct api names of Custom object instead of Employee. Also for Event status 
 
trigger AutoCreateTest 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 ;
}

 
VamsiVamsi
Also pelase make sure to provide required fields and their values of test object while creation 
 
​employees.add(new Employee__c ( Name = '1', Employee__c = newPosition.Id, Role__c = 'Managerial'));
Bold texts are field API names. So make sure to provide required Test object field API names