In order to make this change happen, the following needs to be created and configured in the org:
- Custom Email field
- Workflow rule with field update
- Template in Salesforce Setup
- Email alert
First you will need to create a new field with Data Type 'Email' on the object Step. The field shouldn't be added to the page layouts. Click here for more information concerning creating a custom field.
Then create a Workflow rule with Field update on the object Step to fill the newly created email field with the email address of the hiring manager of the job. Fill in the 'Rule Name'.
Note: It is advised to always fill in the 'Description'.
In the section 'Evaluation Criteria', select: 'created, and every time it's edited'.
In section 'Rule Criteria' > Run this rule if the 'formula evaluates to true'.
In the text box you enter 1<>0
Click on 'Save & Next'.
Click on 'Add Workflow Action' > 'New Field Update'. Fill in the 'Name' then the 'Unique name' will automatically be filled. In 'Field to update' you select the email field you created on object Step.
Check the checkbox 'Re-evaluate Workflow Rules after Field Change'.
Click under 'Specify New Field Value' on 'Use a formula to set the new value' and fill in 'cxsrec__Job_application__r.cxsrec__Position__r.cxsrec__Hiringmanager__r.Email'. Then click on 'Save'.
Then you have you to create Classic email template in Setup. Make sure the checkbox 'Available for use' is checked otherwise it can't be used, therefore it can't be selected in the Email alert.
Then create an Email alert. Fill in all the required fields. The Object should be 'Step'. Select in 'Email Template' the email template you just created. In 'Recipient Type' you select 'Email Field' and the email field you created > click 'Save'.
Finally, you have to create a process with the Process Builder. Name the process and fill in the 'Description'.
The process starts when: a record changes > 'Save'.
Start the process: only when a record is created. > 'Save'.
Click on Add Criteria > fill the Criteria Name.
Criteria for Executing Actions: select Conditions are met
Workflow event id - equals id - fill in the ID of the step
Add another condition
select the email field you created - Does not equal - Global Constant - $GlobalConstant.Null
Immediate action is the Email alert where you select the Email alert that you just created.
Save and activate the process.
You can test if it works by creating a contact record (hiring manager checkbox checked) and link it to a test vacancy. Register a test candidate to the same vacancy by creating a job application and take the step that should trigger an email to the hiring manager. If you receive an e-mail then you're done. If you don't receive an e-mail then go through all the steps of this article again.