Auto-Update Custom Date field using Flow in Salesforce

In Salesforce automation, flows are widely used to automate data processes like creating, updating, and deleting records.

In date fields, we have a standard last activity date field, but this date field gets updated even with small changes in the record, irrespective of the fields. For example, we have a custom date field, Customer review, and we want to track when we updated this field last.

In this Salesforce tutorial, we will learn to Auto-Update Custom Date field using Salesforce Flow. In this example, we will update the Last Review Date field with the help of Salesforce Record Trigger Flow.

Auto-Update Custom Date field using Flow in Salesforce

To Auto-Update the Custom Date field using Flow in Salesforce, you must have a custom date field in that specific object. To create the custom field, you can navigate to the Object Manager -> Object (Contact) -> Fields and relationships -> New field -> select option Date field.

After creating the field follow the below steps to create a record trigger flow to Auto-Update the Custom Date field.

1. Navigate to Salesforce’s Setup page and go to the Quick Find box. Here, search then select Flows under the heading Process automation.

2. In the Flows Setup page, click on the button New Flow.

3. Select the option Record Trigger Flow and click Create.

Auto-update custom date field using flow in Salesforce

4. In the Trigger configuration, select the Object as Task, and then under the heading Trigger flow, select the option when a record is created or updated.

Salesforce Custom Date Update using trigger flow

5. In the section Condtion requirements, according to the below table.

See also  How to Use Record Choice Set in Salesforce Screen Flow
FieldOperatorValue
SubjectContainsClient Review (Custom Date)
StatusEqualsCompleted
ActivityDateIsNullFalse

After this, under the heading When to Run the Flow for Updated Records, select the option Only when a record is updated to meet the condition requirements.

Create a Flow to auto-update a custom date field

6. Now add a Decision element to the flow and enter the Label and API Name for the decision element.

In the section, Outcome details, enter the Label and the Outcome API Name.

Then, in the Conditions Requirements, set the Resource as Record > Name ID (Who id), Operator as Start with, and value as 003 ( Contacts records ID starts from 003).

Update Custom Date field with Flow in Salesforce

7. Add an Update record element to the Flow and enter the below fields.

  • Enter the Label and API Name for the Updated record element.
  • Activate the radio button ‘Update records related to the task record that triggered the flow.’
  • In the Object field, select the Contact object.
Use Salesforce flow to auto-update a date field

8. In the Condition Requirements to Update the Fields, select the option All Conditions Are Met. After this, select the Field as Id, Operator as Equals, and Value as Record > Name ID (here, for the Name ID, select Who ID).

In the section, Set Field Values for Contact Records, select the Fields as Last Client Review (custom date field) and Value as Record > Due Date Only.

How to auto-update custom last activity date using flow in Salesforce

9. In the Default Outcome of the Decision element, add an End component.

Auto-update cutom date field using trigger flow in Salesforce

10. Now save the flow with the relevant Flow Label, and the Flow API Name will be auto-filled according to the entered label. At last, click the Save button.

Auto-update custom date field with flow in Salesforce

The trigger flow is created, and according to the applied condition, any task created related to Client review will update the custom date field Last Client Review in the Contact record.

See also  Create Record Trigger Flow in Salesforce | What is Record Trigger Flow in Salesforce

Debug and test the Flow

We have created the flow to auto-update the custom date field until now. In the below steps, we will debug and test the flow.

1. After saving the Flow, click on the Debug button.

Use Salesforce flow to auto-update a custom Last activity date field

2. Select the option Updated for the condition to run the flow. In the Debug options, skip start condition requirements, select a Task, and click Run.

Use Salesforce Record trigger flow to auto-update a date field

3. Here, we can see that the flow ran successfully without any errors.

Use Record trigger flow to update custom date field in Salesforce

4. Now, activate the flow so that we can use it.

Auto-update custom date field using record trigger flow in Salesforce

5. Navigate to the Contact records and create a new task there, and according to trigger conditions, enter the Subject, Due Date, and Status of the task. You must include the word Client Review in the subject, and the status should be Completed.

Update Custom Date field with trigger Flow in Salesforce

6. As we create the task with the above details, the flow will trigger and it will update the date field with the current date.

How to auto-update custom Date field using Flow in Salesforce

This way, using the above steps, we can auto-update the Custom date fields in Salesforce using flow.

Conclusion

In this Salesforce tutorial, we have learned to Auto-update the Custom Date field using the Flow, where we created a Record Trigger flow to update the field. In addition, we debugged the created flow and tested it in the Salesforce developer Console to ensure its functionality.

You may like to read: