Skip to main content
Brian LaRue が「#Flow」で質問

I am creating a screen flow, interacting as a form, to create a custom object record. Within the flow, I have a record variable where I'll be storing all the values from the form. 

 

Therefore, my first thought was to use record fields. This seems to be the obvious choice as it saves me the hassle of an assignment element and many assignments to set form fields to record variables. However, I'm starting to see several drawbacks of this option.

 

The first issue that I've encountered, it appears that only certain data types are supported as a record field. For example, I have a currency field on the object that I want to collect on the form. Looking through the available fields, I do not see my currency field listed as an available field. Currency fields are not supported as a Record Field? Ok, I guess, that stinks. I'll just use a plain 'ol currency component and an assignment element. No biggie, I guess. Strike 1

 

Moving on, now I have a requirement for some data validation. I need to have the requirement that certain fields need to be populated based on the value of a single picklist. For example:

 

if picklist value = 'a', fields 1, 3, and 5 are required to have a value (not be empty). 

if picklist value = 'b' only field 2 is required to have a value (not be empty).

 

Because all of these fields are not required to have a value on every record, I cannot set the requirement on the object-level. I can only enforce this in the UI. No problem, right?

 

Checking on the fields on the form, it doesn't appear that you can configure data validation on record fields? Ugh. You certainly can do this using vanilla field components. Strike 2

 

Alright, I cannot accept defeat, I'll just need to think outside the box. I'll try to create a formula to do the True/False decision if fields are empty and picklist has a certain value. Then set up a decision element to branch the logic in the flow.

 

Nope, can't do that either. Formulas cannot see inside a Record Field to view the value in the field. Ugh x3. What gives? What?! I have to create the record then immediately get the record to view the values? I don't want to allow creation of the record without passing my custom validation. Double let down. Strike 3

 

Alright, I'll do the data validation on the object level (the backend). Therefore, I created the validation rules and activated them. Then started a Debug on the flow and made an attempt to create the record with known bad data. My thought was that the UI would complain about the error and allow you to correct it (displaying the error message from the Validation Rule). Nope, "An unhandled fault has occurred..." <random non descript message appears>. 

 

Come on Salesforce, we cannot provide a useful error message? Certainly the Validation Rule in the backend is preventing the record from being created as desired. It is very unfortunate that the Validation Rule error cannot bubble up from the backend into the front end and display an actionable message to the user. Triple let down. Strike 4... wait, wasn't I supposed to be out after 3 strikes?

 

So, what I'm asking... are these limitations well-known? Do I just have to skip the record fields for my needs? Do I really need to re-invent the wheel with vanilla components? Am I missing something?

 

@Lightning Flow Discussions 

4 件の回答
  1. 2024年11月19日 11:15

    Hi @Brian LaRue,

     

    What you could do is in the fault path when creating a record show a toast message if the toast message contains FIELD_CUSTOM_VALIDATION do a rollback of previous created or updated records and navigate back to the entre screen where the user can correct that entered data.

    Hi , What you could do is in the fault path when creating a record show a toast message if the toast message contains FIELD_CUSTOM_VALIDATION do a rollback of previous created or updated records and n

0/9000