[SalesForce] Cross-field validation on flow screen input field

The examples for flow field input validation that I'm seeing are evaluating the field that has the validation applied to it itself -eg in this h&t doc

REGEX({!Zipcode},"\\d{5}(-\\d{4})?")

In my flow screen I have a choice with opportunity stages and a close date field.

We have a validation rule that requires close date to be in the future if the opportunity is open, and so I'm trying to implement that logic on the flow screen also (to avoid users hitting the validation rule).

I know I can use a decision element after the screen to evaluate this, but I would hope / assumed that flow input validation could handle this scenario.

I have not been able to get input field validation to work when applying to another field on the screen. However I can get conditional rules to conditionally display a displayText element – I just cant get input validation on close date text input to evaluate the opportunity stage choice input.

I have tried a few variations in the input validation, some of which are copied below. The input validation is set on the close_date screen input, and evaluates the opp_stage screen choice field.

IF(CONTAINS({!Opp_Stage},"Initial"),true,false)
IF(BEGINS({!Opp_Stage},"Initial"),true,false)

The choices are manually defined, not a picklist choice. The choice label and value I am evaluating is 'Initial Conversations'. I have not added the validation for close date yet to the logic bc i just want to get this working. I know I can validate close date as I am applying the validation to close date. Its the cross-field validation that is the issue

Is this not possible? Should I evaluate something else?

Best Answer

To validate against a choice, you cannot evaluate the label / value text - you have to evaluate the choice itself.

So this works for input validation

IF({!Opp_Close_Date} <= TODAY() && 
({!Opp_Stage} = {!InitialConversations} || 
{!Opp_Stage} = {!VerbalCommitment}),false,true)

However, when you click 'next' to proceed and the input validation fires, flow lookup components on the screen reset / lose their value, which is icky. Perhaps there is some workaround for that behavior, but I have decided to go with conditional visibility on a display text element and will put my trust in the peoples ability to read bright red warning text and take evasive action.

a screenshot of the flow with conditional display text warning

Related Topic