In Salesforce, retrieving records is often achieved through the "Get Record" element within a flow. However, in some cases, more intricate methods are necessary. For example, there could be a requirement to retrieve records based on specific criteria or to perform the task only on certain scheduled days.
Our solution caters to these requirements by orchestrating record retrieval for the current month and executing actions exclusively on designated days. This guarantees both the timeliness of the retrieved data and compliance with predefined operational schedules.
In this help article, We'll detail the process of executing a Schedule-Triggered Flow in Salesforce, Designed to run on the 7th day of each month. The Flow objective is to retrieve records with start dates falling within the same month and year as the current date, and subsequently update these records by adding 12 months to their start dates.
Our Flow meticulously verifies the current date to ensure it matches the scheduled execution day. Once confirmed, It systematically fetches all account records categorized as Customer Type and initiated within the ongoing month.
Upon successful retrieval, The Flow proceeds to update the start date of each retrieved account record, Extending it by 12 months. This adjustment ensures that the records accurately reflect the appropriate timeframe for future reference and planning.
The breakdown of the Flow which we created is as follows :
Step 1: Create a Start Date field
Step 2: Create a Flow
Step 3: Create a Formula that checks if the current day matches a specified day
Step 4: Drag and drop a Decision Element onto the canvas
Step 5: Then, Add a Get Records element to the Flow
Step 6: Create a loop in the Flow to iterate through the collection of Account records retrieved
Step 7: For each record, create a Formula to check if the Start Date falls within the same month and year
MONTH({!Loop_through_Account_Records.Start_Date__c}) = MONTH(TODAY()) && YEAR({!Loop_through_Account_Records.Start_Date__c}) = YEAR(TODAY())
Step 8: Set the Decision Element to take the Yes path if the Formula returns True
Step 9: Now create a collection variable of type Record that will hold the accounts with the same month and year
Step 10: In the Yes path of the Decision Element, Add an Assignment Element to the Flow
Step 11: Add a Loop element to the Flow canvas
Step 12: Create a record variable to store the current Account record from the loop
Step 13: Create a Formula resource for adding 12 months to a Start Date
ADDMONTHS({!Loop_Through_List_of_Accounts.Start_Date__c},12)
Step 14: In the loops for each branch, add an Assignment element
Step 15: Create a collection variable of type Record that will hold the accounts that needs to be updated
Step 16: Under the Assignment element added in the Step 15, add another Assignment element
Step 17: Outside the loop, add an Update Records element to the Flow canvas
Testing :
Result :
_________________________________________________________________
Written by: Maham Hassan | Forum Ambassador
Maham Hassan is 2x Mom, Salesforce MVP, Director & Technical Architect @ Cloud-1 & Check Automate, Founder of Dubai Dreamin, 16x Certified, Trailblazer Mentor, Community Group Leader & All Star Ranger.
Submissions reflect only the opinions of the user who made available the Submission and not the opinions of Salesforce, regardless of whether the user is affiliated with Salesforce, and may contain or constitute products, services, information, data, content and other materials made available by or on behalf of third parties ("Third Party Materials). Salesforce neither controls nor endorses, nor is Salesforce responsible for, any Third Party Materials, including their accuracy, validity, timeliness, completeness, reliability, integrity, quality, legality, usefulness or safety, or any applicable intellectual property rights. Any Submissions made available through any message board or forum in response to posted questions, or that otherwise purports to answer any questions, including any questions about Salesforce or Programs, are made available for your general knowledge only and should never be relied upon as answers to your specific questions (even if an answer is marked as a “best” answer or with any similar qualifications). You should always contact Salesforce support for answers to your specific questions. Salesforce has no control over Submissions, and is not responsible for any use or misuse (including any distribution) by any third party of Submissions.
If you have questions, tap into the wisdom of our entire Trailblazer Community here: https://trailhead.salesforce.com/trailblazer-community/feed
001979869

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.