SFDC developer support confirms that if you do a field update in an Approval Process step action and also have a VF (not text/HTML) email alert in the same approval process step action, that VF email alert will NOT merge in the updated-from-the-Field-Update
value into the VF template. This is contrary to the doc which states that field updates occur prior to email alerts.
Note that text/html email alerts will merge in the updated-from-the-Field-Update
value into the generated email.
The workaround, which I confirmed, is to:
- Change the field update in the approval process step to 're-evaluate workflow after update' and
- Remove the email alert from the approval process step's action list and
- Create a normal workflow on your target SObject that tests for the value of the field update in #1 and includes an email alert for your VF email template.
Note that if you do a field update in step i of an approval process, the new value of the field WILL BE available to the email sent to the approvers in step i+1. It is only intrastep VF email alerts that don't get the new value of that step's field updates.
If SFDC support notifies me that this is working-as-designed, expect a doc update; if it is a bug, expect it to appear on Known Issues.
Update - SFDC R&D says this is working as designed -- here is their explanation:
R&D explanation:
########## CAUSE: The VF template queries the database to retrieve the field data, but the TEXT/HTML template shares the Entity > Object (Java) from the Workflow to merge the field data.
SOLUTION/WORKAROUND:
############## customer has 2 solutions here.
Either 1)Customer can use TEXT/HTML email template instead of VF template in approval
process OR
2) Remove email alert(which uses VF template) from approval
process and implement the workflow action to send an email alert(with
VF template) when the status field changes. Need to select
'Re-evaluate Work flow Rules after Field Change' on field update under
approval process.
Personally, I think this explanation needs to be added to the doc as it is counter-intuitive to think that VF email templates associated with WF alerts won't behave the same as text/HTML email templates with the same WF alert.
For your case, Best option is to use the Process Builder
1) Create one Picklist value with "Approved", "Rejected" and "In Process". Put the "In Process" as Default value.
2) Now use "Field Update" in the Approval Process i.e. For Approval, the Field update must be "Approved" and For Rejection, the Field update must be "Rejected".
Note: "Re-evaluate Workflow Rules after Field Change" checkbox must be checked in both "field update" Actions
3) In Process Builder, Create an Object where you are Submitting for Approval.
4) Now In the "Add Criteria" node, put the condition as If the PickList Value is equal to "In Process" and Save the Criteria.
5) Now add the Immediate actions for "Submit for Approval" and Choose "Specific Approval Process in the Option and Give the Name of the Approval Process that you have Created. Save this Action.
6) Create another Action but this time choose,"Create a Record". You can Create any record here in this immediate Action of "Create a Record".
7) Check for the Validation Rules existed in the Object and Give the values for the fields according to those validation rules
8) Now, Save the Immediate actions and Activate the Process Builder.
Best Answer
They will not be guaranteed to fire in the order you see listed, however this will still work out for you.
In Considerations for Field Update Actions that covers creating field updates for workflow rules or approval process:
As such, you should be all set to have the email alert be expected to occur after the field updates.