- Two step approval process on custom object
Foo__c
- initial value of
Foo__c.Status__c
is 'Submitted'
Approval Step 1 actions are threefold:
- Field update on
Foo__c.status__c
= 'Step 1 approved' - Text email alert to recipient list with text body of:
Status: {!Foo__c.status__c}
VF email alert as shown below:
<messaging:emailTemplate subject="some subject" recipientType="User" relatedToType="Foo__c"> <messaging:htmlEmailBody > <html> <apex:outputText value="Status:"/> <apex:outputText value="{!relatedTo.Status__c}"/> </html> </messaging:htmlEmailBody> <messaging:plainTextEmailBody > Status: {!Foo__c.status__c} </messaging:plainTextEmailBody> </messaging:emailTemplate>
Although SFDC doc says that Field Updates execute before Email Alerts in a Workflow, I get the following results:
- Email sent to next step (2) in approval process, email template includes Status = 'Step 1 Approved' [expected result]
- Text-based email sent to recipient with Status = 'Step 1 Approved' [expected result]
- VF email sent to recipient with Status = 'Submitted' [?!? not expected result]
I don't get it.
- Why would the text-based email emitted in Approval Process Step 1 action contain the new (and correct) Field Update value but the VF-based email emitted in the exact same Approval Process Step 1 action does not have the new value?
- It is as if SFDC sends off the VF-based email before the field update has processed contrary to expectations.
...It is really weird behavior and I am escalating this to backline engineers to get resolution.
– cropredy Jan 9 '14 at 1:38In approval process, rather than using an email alert, create a workflow rule on Status update (ex: when status equals 'Approved-step1') and create a workflow action to send an email alert(using VF template). Important thing is, you need to select 'Re-evaluate Workflow Rules after Field Change' on field update under approval process.
– cropredy Jan 17 '14 at 20:22