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
SUYASH KUMAR BHARTISUYASH KUMAR BHARTI 

1ST TRIGGER OF PREVIOUS QUESTION Create Trigger on Hire_form__c 1. When hire_form__c record is insert set status = ‘In Progress’. Create new contact record with firstname , lastname , email, phone. Set contact id in Candidate field on Hire_form object.

Soyab HussainSoyab Hussain
Hi Suyash,
First you have to give your Hire_Form__c field names.
 
Deepali KulshresthaDeepali Kulshrestha
Hi Suyash,

As per your requirement, I have created a trigger to create a contact for every hire form record created.

Here is my class:
public static void HireFormHandler{
    public static void createContact(List<Hire_Form__c> hireFormList){
        try{  
        List<Contact> contactList = new List<Contact>();
        for(Hire_Form__c hf : hireFormList){
            Contact con = new Contact();
            if(hf.First_Name__c!=null)
            con.FirstName = hf.First_Name__c;
            
            if(hf.Last_Name__c!=null)
            con.LastName = hf.Last_Name__c;
            
            if(hf.Email__c!=null)
            con.Email = hf.Email__c;
            
            if(hf.Phone__c!=null)
            con.Phone = hf.Phone__c;
            
            contactList.add(con);
        }
        if(contactList.size()>0)
            insert contactList;
        
        for(Integer i=0i<Hire_Form__c.size();i++){
            Hire_Form__c[i].Candidate__c = contactList[i].Id;
        }
        }catch(Exception e){
            System.debug(e);
        }
    }
}


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com