0

Use Case: When an Opportunity is created or updated, standardize the Name of Opportunity

I created a Record Triggered Flow on Opportunity. The Name populates correctly on Update but on Creation of a new Opportunity record the Name is missing the concatenated CreatedDate.

This is the formula

{!$Record.Account.Name} + "-" +  TEXT({!$Record.Product_Interest__c}) + "-" + TEXT({!$Record.Account.Type}) + "-" +{!$Record.Account.Site} + "-" + TEXT(DATEVALUE({!$Record.CreatedDate}))

Output when new Opportunity record is created

enter image description here

Output when the Opporunity record is updated

enter image description here

Flow enter image description here

2
  • Is this a 'Fast Field Update' flow or a 'Actions and Related Records' flow?
    – Nick C
    Commented Feb 21, 2023 at 23:01
  • @NickCook Fast Field Update Commented Feb 21, 2023 at 23:11

2 Answers 2

1

From the Apex documentation

** Id and createdDate can be detected in before update triggers, but cannot be modified.

So, just like the Id of the record is unavailable in a before inseert trigger, CreatedDate is also unavailable.

Since Fast Field update Flows run before before insert triggers, they too don't have access to CreatedDate

You'll need to use an after-save flow

1

As cropredy has mentioned, the Id and createdDate are not available in a before insert flow.

This doesn't mean you have to move it to an after save flow though.

You can just change your formula to:

{!$Record.Account.Name} + "-" +  TEXT({!$Record.Product_Interest__c}) + "-" + TEXT({!$Record.Account.Type}) + "-" +{!$Record.Account.Site} + "-" + BLANKVALUE(TEXT(DATEVALUE({!$Record.CreatedDate})), TEXT({!$Flow.CurrentDate}))

ie. by using BLANKVALUE(TEXT(DATEVALUE({!$Record.CreatedDate})), TEXT({!$Flow.CurrentDate})), it will use the current date on insert, or the created date otherwise.

I'd personally prefer to do it this way, because performing the change in the after save flow will perform an update on this record, meaning all your triggers/flows will fire again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .