Using Flow to Save Approval Information to Record Fields

Using Flow to Save Approval Information to Record Fields

Approval process is an automation tool that lets users approve records in Salesforce. An approval process can have one or more steps. Using the steps, it is possible to request approval from users and define what to do at each step of the process. You can add actions to initial submission, approval steps, final approval, final rejection, or recall. However, there are only four supported actions.

  • Email alert: Send an email to a recipient using an email template.
  • Task: Create a task record to a specified user.
  • Field update: Update a field of the record.
  • Outbound message: Send a message to a designated endpoint.

If you are familiar with workflow rules, you can see that these are the same actions that are supported by workflow rules. If you want to perform an action that is not listed here, you can perform it by triggering another automation tool. Since Process Builder and Workflow Rules will be retired in the near future, flow is the best option here. Read this post to learn more about the retirement process of these automation tools.

Even though there is an option to update fields, it is very limited. It doesn’t support using values from the process, including the approval or rejection comments. In order to update a field with a value from the process, you have to use a flow. However, how can you trigger a flow from an approval process? Actually, it is simple. You have to update a field and this field update should be the trigger of the flow.

Let’s see an example of saving the approval comment to a field on a case record.

Saving the Approval Comment to a Field on Case Record

Add an Approval Action to the Approval Process

Let’s assume that there is an approval process for the case object. In order to trigger the flow, you have to add a field update as the approval action of the process. In this example, there is only one step in the process and the goal is to save the approval comment. If you need to do the same for more steps or also for rejection, just add a specific action to trigger the flow.

Final approval action

As you can see, at the end of the approval process, there is a field update to mark a checkbox field on the case record. Make sure that you mark “Re-evaluate Workflow Rules after Field Change”.

Field update for approval process
Create a Record Triggered Flow to Save the Approval Comment

Starting with the Spring ’22 release, field changes made by approval processes can run record-triggered flows. Before this release, you had to use a Process Builder in order to trigger your autolaunched flow. Since it is a new feature of the Spring ’22 release, pay attention that you are using API version 54 or higher. Read this post to learn more about this change and the other great features of Spring ’22 release.

1- Create a record-triggered flow. Select case as the object and enter the checkbox field as the criteria. Make sure that the flow runs on update and only when the record is updated to meet the condition requirements.

Depending on your needs, you can make it an after-save flow by selecting “Actions and Related Records”. However, in this example you will just update a field on the same record. So, “Fast Field Updates” is a better option for this example.

Flow start configuration
Flow start conditions

2- Add a Get Records element to get the last Process Instance record related to the case. This is the record that stores the approval process information related to the case.

Get Process Instance

3- Just to make sure, add a Decision element to check if there is a Process Instance record related to the case. Otherwise, there is no reason to continue the flow.

Decision to check the Process Instance for Approval Process

4- Add a Get Records element to get the Process Instance Step related to the Process Instance that you found. This object stores the information of the approval step status related to the approval process. Add another criteria to get the record that has Approved StepStatus. This criteria is needed because the goal is to save the comments that the user wrote while approving. If you want to do it for rejection as well, add a criteria with StepStatus equals to Rejected.

Get Process Instance Item

5- Add a Decision element to check if Process Instance Step exists. If not, there is no reason to continue the flow.

6- Add an Update Records element to update the case record. Comments are stored in the Comments field of the Process Instance Step record. If you need more information such as the approver, you can find the user Id in the ActorId field of the Process Instance Step record.

In order to save the date/time and keep the existing value in the field, create a formula.

Formula to save approval comment
Update case record with approval comments
End of the Flow

This is the end of the flow. Make sure that you activate the flow after saving it. Your flow should look like this.

Record-triggered flow
Approval comments on the record

Since you are triggering a flow, it is possible to perform any kind of actions. You can create, update or delete any record in the system. You can send custom notifications, or post on Chatter, or anything that you need. So it means that, even though the approval process support only four type of actions, it is possible to extend the possibilities using a flow.

23 Comments

  1. I have created the same flow in my org and instead of update I am creating records.While debugging no errors found but the record is not created.

    Can you help with this?

    • Hi,

      Can you make sure that your flow is using the API version 54? Also, make sure that you marked “Re-evaluate Workflow Rules after Field Change” on your field update from the Approval Process.

  2. Very helpful information. In this example, the ‘reset’ field is checked TRUE indefinitely. How would you support multiple approval steps or resubmissions for approval?

    • Hi Ken,
      You just need an indication to trigger the flow. If you have multiple steps or multiple approvals, you can still mark the checkbox when the record is approved. But then unmark the checkbox in the same flow, so that you can use the same logic over and over again.

  3. I am trying to do this with two approval steps but I only get comments to populate from the last step of the approval, any suggestions?

    • Hi,

      In my example I got the first record only but I think you need to get all the records and then use a loop with assignment element.

  4. Hi!
    This is awesome!
    I’m just trying to use the Process Instance to send an Email alert to the Submitter of the request that their request has been approved. So, how do I integrate that into the trigger. Please your guidance will be much appreciated.

    Thank you.

    • Hi,

      I think you can just use the approval action from the approval process. I don’t think that you need a flow for this, unless you have a complex requirement.

      • Hi Yumi!
        Thank you for your response.
        The problem is Salesforce does not have the functionality to send a notification email to the submitter of a record for approval.
        When creating an Email notification within an Approval Process, there is no way to designate the user who submitted the record for approval as a possible recipient of the Email Alert. Currently, the only options are the Record Owner, Created By, Last Modified By, and the standard specific User, Public Group, or Role and Subordinates. It would only make perfect sense that the user who submitted the record for approval would like to be notified when/if the record is approved or rejected.
        I need to be able to send an email alert to the user who submitted the record for approval

        Thank you for your guidance.

        • This is what someone suggested to me:
          To send an Email Alert, look into using a record-triggered flow on the Journal object with an entry criteria of Approval Status = ‘Approved’ that then queries (gets) a “Process Instance” record where TargetObjectId = $Record.Id and Status = ‘Approved’
          I have used this before until I read your blog. But I still don’t how to about using to send an email alert to a submitter.

          • Correct. In this case you cannot use an email alert because you define the recipients on the email alert level (not in the flow), but you don’t know the submitter.
            I think instead of an email alert, you can use the send email core action of flow. You can create the email body in a text template, get the submitter’s email address and put it to the recipient email addresses list (it is an input value for the send email action).

  5. Hi Yumi!
    You are just awesome! This is exactly the directions that I’ve been looking for. No wonder my alert didn’t work when I did it the first time. Your solution works perfectly, I didn’t even think I could use the SF send email core action
    Please keep up the amazing work and don’t stop posting great stuff here.

    Thank you.

  6. Hi Yumi, I have a requirement wherein I need to update a field when approver is reassigned. Is this possible?

    • Hi,
      I think it is not possible. You can run a flow when a request is approved, rejected, or recalled (using the actions from the approval process). However, since it is not possible to add an action when the approver is reassigned, I think you cannot run a flow.

    • Hi Sreeni,
      It is unfortunately not possible to do that. Even if you mark a checkbox that triggers a validation rule, since the main field update is from an approval process, it skips the validation rules.

    • It skips the validation rules but you can use the standard system validations. For example, try to update a lookup field with “You must fill the comments!”.
      Since it is not a valid value for a lookup field, it will give you an error including this text.
      For example I tried it and used a lookup field called “Account Manager”. This is the message that the user gets:
      Account Manager: id value of incorrect type: You must fill the comments!

  7. This is fantastic, thank you for posting! Everything seems to be working for me except the formula. This is the formula I’m using:
    LEFT( TEXT( {{!$Flow.CurrentDateTime} ),16)&”: “&{!Get_Process_Instance_Step.CreatedBy.Alias}&” – “&{!Get_Process_Instance_Step.Comments} &BR()&{!$Record.Approver_Comments__c}
    The date and alias are pulling through, but no comments. I thought maybe it wasn’t working because I’m approving via email, but it also doesn’t work when I approve directly on the record. I confirmed I’m on the latest API version. Any thoughts?
    Thank you!

    • Hi,
      Your formula looks correct but maybe it is not bringing the correct Process Instance Step record. Can you check that record using its Id? You can write a query in developer console or just navigate to that record to see if there is a value in the comments field.

  8. Hi Yumi. I have a requirement to save approval comments from multi level approvers not only the final approver. How can I do that ?

    • Hi,
      Instead of getting the first Process Instance Step, you can get all the records that meet the criteria. This will store them in a record collection. Then you have to use a loop and assignment to prepare a variable that contains all of the comments.

Leave a Reply

Your email address will not be published.


*