Business Challenge
When an opportunity is closed, the related Tasks are left open. This results in supply chain, engineers and others will be working on their tasks even though the opportunity has been closed.
This can be resolved by creating a Record Triggered Flow which would Update the Related Tasks status to Completed and also send notification to the task owners as soon as the Opportunity is Closed
Steps to achieve the requirement
- Create custom Notification
- Create Flow
Create Custom Notification
-
From the home page, click on the Gear Icon at the top and then click on Setup.
-
From the Quick Find search and select Custom Notification → Click New.
-
Enter Custom Notification Name as Task Update Notification →Under Supported Channels Check on the Desktop and Mobile checkboxes → Click Save.
Create Flow
-
From the Quick Find search and select Flows → Click New Flow.
-
Select Record Trigger Flow → Click Create.
-
Select Opportunity as the Object → Under Configure Trigger, for Trigger the flow when option Choose A Record is Updated.
-
Under Set Entry Conditions, for Condition Requirements choose Any Condition is Met (OR) → Select Stage Name as Field, Equals as Operator and Closed Won as Value → Add Condition and make it as Stage Name Equals Closed Lost.
-
Under When to Run the Flow for Updated Records Select Only when a record is updated to meet the condition requirements → For Optimize the flow for option Select Actions and Related Records.
-
Click Done.
-
Make sure the Layout is Auto Layout.
-
Click (+) Icon under the start element → Select Update Records Element.
-
Enter Label as Update Task Records → Under How to Find Records to Update and Set their Values select Specify Conditions to identify records, and Set fields individually → Select Task as the Object.
-
Under Filter Task Records, for Condition Requirements to Update Records option choose All Conditions Are Met(AND). Add Filter Condition as WhatId Equals Record > Opportunity ID.
-
Under Set Field Values for the Task Records choose Description as Field and Enter Opportunity related to this Task is Closed as the Value → Click Add Field.
-
Choose Status as Field and Select Completed as the value.
-
Click Done.
-
Click (+) icon → Select Get Records Element.
-
Enter Label as Get Custom Notification → Select Custom Notification Type as Object.
-
Under Condition Requirements choose All Conditions Are Met (AND). Choose Developer Name as Field , Equals as Operator, Enter Task_Update_Notification(API name) as Value → select Ascending as Sort Order → Choose Id for Sort By.
-
For How many Records to Store Select Only the first record → For How to Store Record Data select Automatically Store all fields.
-
Click Done.
-
Click (+) icon Under Get Custom Notification element → Click Get Records Element.
-
Enter Label as Get Task → Select Task as the Object.
-
Under Filter Task Records choose All Conditions Are Met (AND) Choose WhatID as Field, Equals as Operator and Record > Opportunity ID as Value. Under Sort Task Records, select Ascending as Sort Order and Id for Sort By.
-
Select All records under How many records to store → Select Automatically Store all fields under How to store record Data → Click Done.
-
Click (+) icon under Get Tasks element → Select Loop Element.
-
Enter Label as Loop Task Records → Select Tasks from Get_Task.
-
Under Specify Direction for Iterating Over Collection Select First Item to Last Item as the Direction.
-
Click Done.
-
Click (+) icon.
-
Select Assignment Element.
-
Enter Label as Owner ID Collection → Create New Resource as a Variable.
-
Select Variable as Resource type → Enter OwnerID as API Name → Select Text as Data Type → Check the Allow Multiple values (Collection).
-
Click Done.
-
Select Add as Operator.
-
Select Current Item from Loop Loop_Task_Records > .OwnerId.
-
.Click Done.
-
Click (+) icon under Owner Id Collection element → Select Action Element.
-
Enter Custom in the search Actions box → Select Send custom Notification.
-
Enter Label as Task Close Notification→ Select Custom Notification Type Id from Get_Custom_Notification > Id.
-
For the Notification Body create a New Resource.
-
Select Resource Type as Text Template → Enter API Name as Notification_Body.
-
Change the View as Rich Text to View as Plain Text → Copy the below content and Paste inside the Body.
Hi {!Looping_Task_Records.Owner:User.FirstName} {!Looping_Task_Records.Owner:User.LastName},
The Task "{!Looping_Task_Records.Subject} " is closed and Respective Opportunity is completed.
Regards,
{!$Record.Owner.FirstName} {!$Record.Owner.LastName}
(In Task record there is no full name that is the reason here First Name and Last Name are used)
-
Enter Task Close Notification text as the Value for Notification Title→ Add Recipient IDs as OwnerId (Collection Variable).
-
Include Target ID → Select {!$Record.Id} (Opportunity Id).
-
Click Done.
-
Click Save at the top right corner.
-
Enter Flow Name as Update Tasks and Send Notifications → Click Save.
-
Activate the Flow.
Testing the Flow
I picked one Opportunity record Grand Hotel Generator Installation (Opportunity stage is not Closed). This opportunity has 2 Upcoming Tasks
Once the opportunity stage is changed to Closed Won / Closed Lost the respected Task status updated to completed, Description field is updated and Notification is sent to Task Owners.
Like the below Image It will send Notification to the Task Owner.
It also updates Task Status and Comment (Description). Please refer the below screenshot.
WRAPPING IT UP
In this Blog we have covered how to update the related Tasks statuses, update the Comments for status Change and send Notifications to the Task Owners using a Record Trigger Flow.
Leave a Comment