+ Start a Discussion
Aniket Supe 6Aniket Supe 6 

Trigger (OnCandidateHireDeactivateJob)

Write a trigger on Candidate object to do the following -
Name: OnCandidateHireDeactivateJob_Yourname
Job has a field called Active (checkbox), If job is active and Candidate for that Job is being hired, trigger should calculate total number of Candidates hired so far including the current one and check if it exceeds or equals to number of open position on the Job. If it exceeds or equals, the Job's Active fields should be set to false (unchecked) so the Job is taken out from Active Job lists hence Candidates can not apply for it anymore
Job manager should be allowed to hire n number of Candidates. Where n= Number of Open Positions. Throw error when Job Manager Hire Candidates beyond Number of Open Positions limit stating "Sorry, No vacancies available for this Job"

Once Job is deactivated, new Candidates should not be allowed to apply for particular deactivated job. Provide error for such Candidates who are applying for Deactivated Job stating "Sorry, Job does not exist"
If more than one Candidate is being hired for the Job at a time, throw an error for such 
Candidates stating "At a time only one Candidate can be hired for a Job"