Skip to main content

TLDR: The Review record I created was the 10th one I've created today, and therefore my User record should be flagged and send an email alert and a custom notification, but the flow cannot locate the other 9 reviews.

 

==============================================================

Business need:

 

Designated users want 1) to be notified in and outside of Salesforce when a user creates a large # of Review records in a single day.

 

In addition to sending out an Email Alert and Custom Notification when someone creates too many Review records, 2) the business requires that a user is also "flagged" if they create more than a certain # of Review records related to a single Movie. 3) Last, this user should be unable to create any more Review records as a result of this flag.

 

==============================================================

New Fields on User record: 

 

  • Today's_Review_Count__c         (Number field)
  • Flagged                                          (Formula checkbox field: Today_s_Review_Count__c > 9)

 

My Flow: Record-Triggered 

 

Start Element: I have a record-triggered flow for when a Review record is created and there are no condition requirements. 

 

Get Records Element: Captures these fields from the User who created the Review record:

  1. User ID
  2. Flagged__c (Formula checkbox)
  3. Today_s_Review_Count__c (Number)

Get Records Element: Captures fields from all other Review records created by User found in last Get Records Element:

  1. ID
  2. Created_Date__c
  3. CreatedById
  4. Movie__c

Assignment Element: Gets count of Review records found in last Get Records Element:

 

varNCount (number variable) Equals Count reviewsFound (record collection variablel)

 

Update Records Element: Updates User record where Id = $Record > Created By Id

 

Field: Today_s_Review_Count__c <- Value: VarNCount

 

 

Decision Element: If VarNCount > 9 and $Record > Created Date Equals TODAY(), follow "Yes" branch

 

Yes: 

 

Get Records Element: Captures all User record IDs with the System Administrator profile ID and stores them in sysAdminUsers record collection variable.

 

Assignment Element: Assign sysAdminUsers to sysAdminIds text collection variable.

 

Get Records Element: Captures Custom Notification Id of notifications with DeveloperName = (my custom notification API name)

 

Send Email Alert: {!$Record.Id}

 

Send Custom Notification Element: 

 

Custom Notification Type ID: {!Get_Custom_Notifications.Id}

Notification Body: {!textBody}

Notification Title: {!textTitle}

Recipient IDs: {!sysAdminids1}

Target ID: {!userId}

 

==============================================================

Results: 

 

The Review record I created was the 10th one I've created today, but the flow cannot locate the other 9 reviews.

 

Debug / Rollback mode

 

How the Interview Started: 

This debug run was triggered as if the review__c record was created.

Jenna Hill (0058b00000GorSi) started the flow interview.

API Version for Running the Flow: 57

Some of this flow's variables were set when the interview started.

$Record = Review__c (a018b000010fOUyAAM)

Flow start time: May 22, 2023 at 5:08 PM.

 

Entry Conditions: 

The triggering record met the condition requirements.

Entry Conditions

null

 

Get Records: Get User Record

Find one User record where

Id Equals {!$Record.CreatedById} (0058b00000GorSiAAJ)

Result

Successfully found record.

{!flagged} = false

{!userId} = 0058b00000GorSiAAJ

{!todaysReviewCount} = 0

 

***Get Records: Get Reviews***

Find all Review__c records where

CreatedById Equals {!userId} (0058b00000GorSiAAJ)

AND Created_Date__c Equals {!Today} (May 22, 2023)

Store those records in {!reviewsFound}.

Save these field values in the variable: Id, Created_Date__c, CreatedById, Movie__c

Result: Failed to find records.

 

Assignment: Get Count of Reviews

{!VarNCount} Assign Count {!reviewsFound}

 

Update Records: Update User Review Count

Find all User records where

Id Equals {!$Record.CreatedById} (0058b00000GorSiAAJ)

Update the records’ field values.

Today_s_Review_Count__c = {!VarNCount} (0)

Result

All records that meet the filter criteria are ready to be updated when the next screen, pause, or local action is executed or when the interview finishes.

 

Decision: Greater Than 9?

Skipped this outcome because its conditions weren't met: Yes_Greater_than_9

Outcome conditions

1. {!VarNCount} (0) Greater than 9

2. {!$Record.Created_Date__c} (null) Equals {!Today} (May 22, 2023)

Logic: All conditions must be true (AND)

Default outcome executed.

11 Antworten
  1. 23. Mai 2023, 15:47

    Thank you for your contributions, everyone! I was able to find a solution through a contact in #OhanaSlack!

0/9000