Valid If expression needs exceptions for Copy Record

Hello, I have actions configured for copying a parent/child scenario - Job Order Header/Job Order Detail. Both the the job order header & detail have valid if expressions in place preventing the user and another field from being duplicated but since the same job order is being copied with the same job order no (not a unique id or key), its ok to make the copy When I run the copy, it fails as a result of the duplication.

Here’s my expression for the user id that’s failing with my attempt and stating if the user is in the lis but its the same job order its ok to include it in the listing.

SELECT(users[Email],OR([vir_user_assigned]=FALSE,[vir_job_order_no]=[_THISROW].[vir_job_order_no]))

Is there a way to indicate exceptions to the Valid ifs in an expression? I have this issue in many areas of my app so any help on thinking this one through would be outstanding.

A million thanks

Yes, as it’s an expression, so you can handle any exception that can be expressed by an expression. The problem here is that an expression can’t inherently recognize it’s being evaluated in the context of an action.

Are you trying to use App: copy this row and edit the copy?

1 Like

Thanks Steve, I’m using:

Data: Add a new row to another table using values from this row

1 Like

And it’s ultimately okay if the new row has the duplicate (non-key) values?

1 Like

Yes

You could try using a CONTEXT() expression. There are several possible approaches, such as to apply the current Valid If expression only in forms:

IF(
  ("form" <> CONTEXT("ViewType")),
  LIST([_THIS]),
  expression-for-forms
)
  1. CONTEXT("ViewType") gets the view type (e.g., detail, form, gallery) of the view currently displayed to the user.

  2. ("form" <> ...) asks, is the currently-displayed view not a form-type view?

  3. LIST([_THIS]) sets the list of valid values for the column to the value it currently has if and only if the answer to (2) is “yes” (i.e., the user is not in a form).

  4. Replace expression-for-forms with the expression you want to use if and only if the answer to (2) is “no” (i.e., the user is in a form).

Based on the SELECT() expression you provided, it appears you’re using Valid If to provide the form user with a dropdown menu, so I’ve structured my expression for that. We’d have to tweak the expression if you instead want a simple valid/invalid result.

3 Likes

Thanks Steve, I’m digesting this now and will check back.

Thanks again

1 Like

Hi Steve it worked! I’m testing in several other areas now.

A million thanks for your help as always!

1 Like

Whoo-hoo! :smiley: